From 1faae224be3e1a9a33bacb6756353df16e6a6409 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Mon, 4 Dec 2017 08:01:33 +0300 Subject: [PATCH 01/25] added tooltips with shader node documentations. --- .../shader/nodes/ui/PluginCSSClasses.java | 1 + .../editor/ShaderNodesFileEditor.java | 10 ++- .../shader/nodes/ShaderNodeElement.java | 18 ++++- .../action/add/AddNodeShaderNodeAction.java | 2 +- .../nodes/main/MainShaderNodeElement.java | 8 ++ .../tooltip/SndDocumentationTooltip.java | 81 +++++++++++++++++++ .../property/ShaderNodesPropertyBuilder.java | 17 +++- .../com/ss/editor/shader/nodes/style.css | 5 ++ 8 files changed, 135 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/PluginCSSClasses.java b/src/main/java/com/ss/editor/shader/nodes/ui/PluginCSSClasses.java index a1fe80f..9427f02 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/PluginCSSClasses.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/PluginCSSClasses.java @@ -24,4 +24,5 @@ public interface PluginCSSClasses { @NotNull String SHADER_CODE_PREVIEW_CONTAINER = "shader-code-preview-component"; @NotNull String SHADER_NODE_DEF_DOCUMENTATION_DIALOG = "shader-node-def-documentation-dialog"; + @NotNull String SHADER_NODE_DEF_DOCUMENTATION_TOOLTIP = "shader-node-def-documentation-tooltip"; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index 4b59954..9c32eb0 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -13,6 +13,7 @@ import com.jme3.material.logic.*; import com.jme3.material.plugin.export.materialdef.J3mdExporter; import com.jme3.material.plugins.J3MLoader; +import com.jme3.material.plugins.ShaderNodeLoaderDelegate; import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; @@ -219,7 +220,14 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { final StreamAssetInfo assetInfo = new StreamAssetInfo(assetManager, tempKey, materialDefStream); final J3MLoader loader = new J3MLoader(); - final MaterialDef materialDef = (MaterialDef) loader.load(assetInfo); + final MaterialDef materialDef; + + ShaderNodeLoaderDelegate.setForceLoadDocumentation(true); + try { + materialDef = (MaterialDef) loader.load(assetInfo); + } finally { + ShaderNodeLoaderDelegate.setForceLoadDocumentation(false); + } materialDef.getTechniqueDefsNames().forEach(techniqueDefName -> { materialDef.getTechniqueDefs(techniqueDefName).forEach(techniqueDef -> { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java index f2be49c..4549657 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java @@ -22,6 +22,7 @@ import javafx.scene.Cursor; import javafx.scene.Parent; import javafx.scene.control.Label; +import javafx.scene.control.Tooltip; import javafx.scene.input.ContextMenuEvent; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; @@ -30,6 +31,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Optional; + /** * The base implementation of shader nodes. * @@ -106,15 +109,16 @@ public String getName() { public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull final T object) { this.container = container; + this.object = object; + this.parametersContainer = new VBox(); setOnMousePressed(this::handleMousePressed); setOnMouseDragged(this::handleMouseDragged); setOnMouseMoved(this::handleMouseMoved); setOnMouseReleased(this::handleMouseReleased); setOnContextMenuRequested(this::handleContextMenuRequested); - this.object = object; - this.parametersContainer = new VBox(); createContent(); setPrefWidth(200); + createTooltip().ifPresent(tooltip -> Tooltip.install(this, tooltip)); FXUtils.addClassTo(this, SHADER_NODE); } @@ -128,6 +132,16 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull return parametersContainer; } + /** + * Create a tooltip of this node element. + * + * @return the tooltip. + */ + @FXThread + protected @NotNull Optional createTooltip() { + return Optional.empty(); + } + /** * Handle the context menu requested events. * diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java index 8151304..a7f8d22 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java @@ -69,7 +69,7 @@ protected void process() { private void addNode(@NotNull final String resource) { final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(resource); - key.setLoadDocumentation(false); + key.setLoadDocumentation(true); final AssetManager assetManager = EDITOR.getAssetManager(); final List definitions = assetManager.loadAsset(key); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java index f2df7e4..d8bf0bc 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java @@ -18,13 +18,16 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.tooltip.SndDocumentationTooltip; import com.ss.rlib.ui.util.FXUtils; import com.ss.rlib.util.StringUtils; +import javafx.scene.control.Tooltip; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Optional; /** * The implementation of shader element to present shader nodes. @@ -43,6 +46,11 @@ public MainShaderNodeElement(@NotNull final ShaderNodesContainer container, @Not return getObject().getDefinition().getName(); } + @Override + @FXThread + protected @NotNull Optional createTooltip() { + return Optional.of(new SndDocumentationTooltip(getObject().getDefinition())); + } @FXThread @Override diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java new file mode 100644 index 0000000..c30f136 --- /dev/null +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java @@ -0,0 +1,81 @@ +package com.ss.editor.shader.nodes.ui.component.shader.nodes.tooltip; + +import static com.ss.rlib.util.ObjectUtils.notNull; +import com.jme3.shader.ShaderNodeDefinition; +import com.ss.editor.annotation.FXThread; +import com.ss.editor.shader.nodes.ui.PluginCSSClasses; +import com.ss.editor.shader.nodes.ui.component.SndDocumentationArea; +import com.ss.editor.ui.tooltip.CustomTooltip; +import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.util.StringUtils; +import javafx.scene.layout.BorderPane; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The tooltip with documentation of shader node definition. + * + * @author JavaSaBr + */ +public class SndDocumentationTooltip extends CustomTooltip { + + @NotNull + private final ShaderNodeDefinition definition; + + @Nullable + private SndDocumentationArea documentation; + + public SndDocumentationTooltip(@NotNull final ShaderNodeDefinition definition) { + this.definition = definition; + } + + @Override + @FXThread + protected @NotNull BorderPane createRoot() { + return new BorderPane(); + } + + @Override + @FXThread + protected void createContent(@NotNull final BorderPane root) { + super.createContent(root); + this.documentation = new SndDocumentationArea(); + this.documentation.setEditable(false); + root.setCenter(documentation); + FXUtils.addClassesTo(documentation, PluginCSSClasses.SHADER_NODE_DEF_DOCUMENTATION_TOOLTIP); + } + + /** + * Get the definition. + * + * @return the definition. + */ + @FXThread + private @NotNull ShaderNodeDefinition getDefinition() { + return definition; + } + + /** + * Get the area to show documentation. + * + * @return the area to show documentation. + */ + @FXThread + private @NotNull SndDocumentationArea getDocumentation() { + return notNull(documentation); + } + + @Override + @FXThread + protected void show() { + + final ShaderNodeDefinition definition = getDefinition(); + final String documentation = definition.getDocumentation(); + + if (!StringUtils.isEmpty(documentation)) { + getDocumentation().reloadContent(documentation); + } + + super.show(); + } +} diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java index cf4dba0..5ba86ff 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java @@ -16,6 +16,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.EnumSet; import java.util.List; /** @@ -25,6 +26,12 @@ */ public class ShaderNodesPropertyBuilder extends EditableObjectPropertyBuilder { + @NotNull + private static final EnumSet NOT_AVAILABLE_DEFAULT_VALUE = EnumSet.of( + GLSLType.SAMPLER_2D, + GLSLType.SAMPLER_CUBE + ); + /** * The single instance. */ @@ -65,13 +72,17 @@ protected ShaderNodesPropertyBuilder() { } else if (object instanceof ShaderNodeVariable) { final ShaderNodeVariable variable = (ShaderNodeVariable) object; + final GLSLType glslType = GLSLType.ofRawType(variable.getType()); result.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_TYPE, variable, var -> GLSLType.ofRawType(var.getType()), (var, type) -> var.setType(type.getRawType()))); - result.add(new SimpleProperty<>(STRING, Messages.MODEL_PROPERTY_DEFAULT_VALUE, variable, - ShaderNodeVariable::getDefaultValue, - ShaderNodeVariable::setDefaultValue)); + + if (!NOT_AVAILABLE_DEFAULT_VALUE.contains(glslType)) { + result.add(new SimpleProperty<>(STRING, Messages.MODEL_PROPERTY_DEFAULT_VALUE, variable, + ShaderNodeVariable::getDefaultValue, + ShaderNodeVariable::setDefaultValue)); + } } return result; diff --git a/src/main/resources/com/ss/editor/shader/nodes/style.css b/src/main/resources/com/ss/editor/shader/nodes/style.css index ea2de47..7e65f37 100644 --- a/src/main/resources/com/ss/editor/shader/nodes/style.css +++ b/src/main/resources/com/ss/editor/shader/nodes/style.css @@ -120,4 +120,9 @@ .shader-node-def-documentation-dialog { -fx-min-height: 400px; -fx-min-width: 500px; +} + +.shader-node-def-documentation-tooltip { + -fx-min-height: 150px; + -fx-min-width: 500px; } \ No newline at end of file From b468c9b5055cd69adc558e911109ef9cd06b758c Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Mon, 4 Dec 2017 12:41:47 +0300 Subject: [PATCH 02/25] updated implementation of documentation preview. --- .../component/editor/ShaderNodesFileEditor.java | 10 +--------- .../add/AddMaterialParamShaderNodeAction.java | 2 +- .../nodes/tooltip/SndDocumentationTooltip.java | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index 9c32eb0..4b59954 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -13,7 +13,6 @@ import com.jme3.material.logic.*; import com.jme3.material.plugin.export.materialdef.J3mdExporter; import com.jme3.material.plugins.J3MLoader; -import com.jme3.material.plugins.ShaderNodeLoaderDelegate; import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; @@ -220,14 +219,7 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { final StreamAssetInfo assetInfo = new StreamAssetInfo(assetManager, tempKey, materialDefStream); final J3MLoader loader = new J3MLoader(); - final MaterialDef materialDef; - - ShaderNodeLoaderDelegate.setForceLoadDocumentation(true); - try { - materialDef = (MaterialDef) loader.load(assetInfo); - } finally { - ShaderNodeLoaderDelegate.setForceLoadDocumentation(false); - } + final MaterialDef materialDef = (MaterialDef) loader.load(assetInfo); materialDef.getTechniqueDefsNames().forEach(techniqueDefName -> { materialDef.getTechniqueDefs(techniqueDefName).forEach(techniqueDef -> { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java index 81ded75..6969089 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java @@ -48,7 +48,7 @@ public class AddMaterialParamShaderNodeAction extends ShaderNodeAction VAR_TYPES = ArrayFactory.newArray(String.class); + private static final Array VAR_TYPES = ArrayFactory.newArray(String.class); static { for (final VarType varType : VarType.values()) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java index c30f136..5d7e510 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java @@ -1,7 +1,10 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.tooltip; import static com.ss.rlib.util.ObjectUtils.notNull; +import com.jme3.asset.AssetManager; +import com.jme3.asset.ShaderNodeDefinitionKey; import com.jme3.shader.ShaderNodeDefinition; +import com.ss.editor.Editor; import com.ss.editor.annotation.FXThread; import com.ss.editor.shader.nodes.ui.PluginCSSClasses; import com.ss.editor.shader.nodes.ui.component.SndDocumentationArea; @@ -19,6 +22,9 @@ */ public class SndDocumentationTooltip extends CustomTooltip { + @NotNull + private static final Editor EDITOR = Editor.getInstance(); + @NotNull private final ShaderNodeDefinition definition; @@ -70,7 +76,14 @@ protected void createContent(@NotNull final BorderPane root) { protected void show() { final ShaderNodeDefinition definition = getDefinition(); - final String documentation = definition.getDocumentation(); + final ShaderNodeDefinitionKey assetKey = new ShaderNodeDefinitionKey(definition.getPath()); + assetKey.setLoadDocumentation(true); + + final AssetManager assetManager = EDITOR.getAssetManager(); + final String documentation = assetManager.loadAsset(assetKey).stream() + .filter(def -> def.getName().equals(definition.getName())) + .map(ShaderNodeDefinition::getDocumentation) + .findAny().orElse(""); if (!StringUtils.isEmpty(documentation)) { getDocumentation().reloadContent(documentation); From 132eeaec9f4ed97f78978504d89a0921919f79b7 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Fri, 8 Dec 2017 07:25:04 +0300 Subject: [PATCH 03/25] fixed showing documentation. --- build.gradle | 2 +- .../shader/nodes/tooltip/SndDocumentationTooltip.java | 4 ++-- .../shader/nodes/ui/dialog/EditSndDocumentationDialog.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 4c89bf2..cc3ba41 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ configurations { } dependencies { - compile 'com.github.JavaSabr:jmonkeybuilder:develop-SNAPSHOT' + compile 'com.github.JavaSaBr:jmonkeybuilder:develop-SNAPSHOT' testCompile "org.junit.platform:junit-platform-commons:$junitPlatformVersion" testRuntime "org.junit.platform:junit-platform-engine:$junitPlatformVersion" diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java index 5d7e510..5a114ea 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/tooltip/SndDocumentationTooltip.java @@ -80,13 +80,13 @@ protected void show() { assetKey.setLoadDocumentation(true); final AssetManager assetManager = EDITOR.getAssetManager(); - final String documentation = assetManager.loadAsset(assetKey).stream() + String documentation = assetManager.loadAsset(assetKey).stream() .filter(def -> def.getName().equals(definition.getName())) .map(ShaderNodeDefinition::getDocumentation) .findAny().orElse(""); if (!StringUtils.isEmpty(documentation)) { - getDocumentation().reloadContent(documentation); + getDocumentation().reloadContent(documentation.trim()); } super.show(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java index f39a8b2..9e40865 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java @@ -53,7 +53,7 @@ public EditSndDocumentationDialog(@NotNull final ChangeConsumer consumer, this.consumer = consumer; this.definition = definition; final String documentation = definition.getDocumentation(); - getEditorArea().loadContent(documentation == null ? "" : documentation); + getEditorArea().loadContent(documentation == null ? "" : documentation.trim()); } /** From f6ed8ea819f263c14a1b1426043e87b3452f9b5d Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Fri, 8 Dec 2017 09:45:10 +0300 Subject: [PATCH 04/25] added value mappings. --- .../materialdef/J3mdTechniqueDefWriter.java | 339 +++++ .../plugins/ShaderNodeLoaderDelegate.java | 1123 +++++++++++++++++ src/main/java/com/jme3/shader/ShaderNode.java | 294 +++++ .../com/jme3/shader/ShaderNodeVariable.java | 343 +++++ .../java/com/jme3/shader/ValueMapping.java | 97 ++ .../java/com/jme3/shader/VariableMapping.java | 207 +++ 6 files changed, 2403 insertions(+) create mode 100644 src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java create mode 100644 src/main/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java create mode 100644 src/main/java/com/jme3/shader/ShaderNode.java create mode 100644 src/main/java/com/jme3/shader/ShaderNodeVariable.java create mode 100644 src/main/java/com/jme3/shader/ValueMapping.java create mode 100644 src/main/java/com/jme3/shader/VariableMapping.java diff --git a/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java b/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java new file mode 100644 index 0000000..41a637c --- /dev/null +++ b/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java @@ -0,0 +1,339 @@ +/* + * 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. + */ +package com.jme3.material.plugin.export.materialdef; + +import com.jme3.material.MatParam; +import com.jme3.material.RenderState; +import com.jme3.material.TechniqueDef; +import com.jme3.shader.*; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.Collection; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author nehon + */ +public class J3mdTechniqueDefWriter { + + public J3mdTechniqueDefWriter() { + } + + public void write(TechniqueDef techniqueDef, Collection matParams, OutputStreamWriter out) throws IOException { + out.write(" Technique"); + if(!techniqueDef.getName().equals("Default")) { + out.write(" "); + out.write(techniqueDef.getName()); + } + out.write(" {\n"); + + //Light mode + if(techniqueDef.getLightMode() != TechniqueDef.LightMode.Disable ){ + out.write(" LightMode "); + out.write(techniqueDef.getLightMode().name()); + out.write("\n\n"); + } + + //Shadow mode + if(techniqueDef.getShadowMode() != TechniqueDef.ShadowMode.Disable ){ + out.write(" ShadowMode "); + out.write(techniqueDef.getShadowMode().name()); + out.write("\n\n"); + } + + //Shaders + if(!techniqueDef.isUsingShaderNodes()) { + writeShaders(techniqueDef, out); + } + + //World params + if(!techniqueDef.getWorldBindings().isEmpty()){ + writeWorldParams(techniqueDef, out); + } + + //ShaderNodes + if(techniqueDef.isUsingShaderNodes()){ + writeShaderNodes(techniqueDef, matParams, out); + + } else { + //When we have ShaderNodes, Defines are handled differently so we don't have to write them. + //Defines + if (techniqueDef.getDefineNames().length != 0) { + writeDefines(techniqueDef, matParams, out); + } + } + + //render state + RenderState rs = techniqueDef.getRenderState(); + if(rs != null){ + out.write(" RenderState {\n"); + writeRenderState(rs, out); + out.write(" }\n\n"); + } + + //forced render state + rs = techniqueDef.getForcedRenderState(); + if(rs != null){ + out.write(" ForcedRenderState {\n"); + writeRenderState(rs, out); + out.write(" }\n\n"); + } + + //no render + if(techniqueDef.isNoRender()){ + out.write(" NoRender\n\n"); + } + + out.write(" }\n"); + } + + private void writeDefines(TechniqueDef techniqueDef, Collection matParams, OutputStreamWriter out) throws IOException { + out.write(" Defines {\n"); + + for (int i = 0; i < techniqueDef.getDefineNames().length; i++) { + String matParamName = getMatParamNameForDefineId(techniqueDef, matParams, i); + if (matParamName != null) { + String defineName = techniqueDef.getDefineNames()[i]; + out.write(" "); + out.write(defineName); + out.write(": "); + out.write(matParamName); + out.write("\n"); + } + } + out.write(" }\n\n"); + } + + private void writeShaderNodes(TechniqueDef techniqueDef, Collection matParams, OutputStreamWriter out) throws IOException { + out.write(" VertexShaderNodes {\n"); + for (ShaderNode shaderNode : techniqueDef.getShaderNodes()) { + if(shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex){ + writeShaderNode(out, shaderNode, matParams); + } + } + out.write(" }\n\n"); + + out.write(" FragmentShaderNodes {\n"); + for (ShaderNode shaderNode : techniqueDef.getShaderNodes()) { + if(shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment){ + writeShaderNode(out, shaderNode, matParams); + } + } + out.write(" }\n\n"); + } + + private void writeWorldParams(TechniqueDef techniqueDef, OutputStreamWriter out) throws IOException { + out.write(" WorldParameters {\n"); + for (UniformBinding uniformBinding : techniqueDef.getWorldBindings()) { + out.write(" "); + out.write(uniformBinding.toString()); + out.write("\n"); + } + out.write(" }\n\n"); + } + + private void writeShaders(TechniqueDef techniqueDef, OutputStreamWriter out) throws IOException { + if (techniqueDef.getShaderProgramNames().size() > 0) { + for (Shader.ShaderType shaderType : techniqueDef.getShaderProgramNames().keySet()) { + // System.err.println(shaderType + " " +techniqueDef.getShaderProgramNames().get(shaderType) + " " +techniqueDef.getShaderProgramLanguage(shaderType)) + out.write(" "); + out.write(shaderType.name()); + out.write("Shader "); + out.write(techniqueDef.getShaderProgramLanguage(shaderType)); + out.write(": "); + out.write(techniqueDef.getShaderProgramNames().get(shaderType)); + out.write("\n"); + } + out.write("\n"); + } + } + + private void writeShaderNode( OutputStreamWriter out, ShaderNode shaderNode, Collection matParams) throws IOException { + out.write(" ShaderNode "); + out.write(shaderNode.getName()); + out.write(" {\n"); + + if (shaderNode.getCondition() != null){ + out.write(" Condition: "); + out.write(formatCondition(shaderNode.getCondition(), matParams)); + out.write("\n"); + } + + out.write(" Definition: "); + out.write(shaderNode.getDefinition().getName()); + out.write(": "); + out.write(shaderNode.getDefinition().getPath()); + out.write("\n"); + + final List inputMapping = shaderNode.getInputMapping(); + final List outputMapping = shaderNode.getOutputMapping(); + final List valueMapping = shaderNode.getValueMapping(); + + if (!inputMapping.isEmpty()) { + out.write(" InputMappings {\n"); + for (VariableMapping mapping : inputMapping) { + writeVariableMapping(out, shaderNode, mapping, matParams); + } + out.write(" }\n"); + } + + if (!outputMapping.isEmpty()) { + out.write(" OutputMappings {\n"); + for (VariableMapping mapping : outputMapping) { + writeVariableMapping(out, shaderNode, mapping, matParams); + } + out.write(" }\n"); + } + + if (!valueMapping.isEmpty()) { + out.write(" ValueMappings {\n"); + for (ValueMapping mapping : valueMapping) { + writeValueMapping(out, mapping); + } + out.write(" }\n"); + } + + out.write(" }\n"); + } + + private void writeVariableMapping(final OutputStreamWriter out, final ShaderNode shaderNode, + final VariableMapping mapping, final Collection matParams) + throws IOException { + + final ShaderNodeVariable leftVar = mapping.getLeftVariable(); + final ShaderNodeVariable rightVar = mapping.getRightVariable(); + + out.write(" "); + + if (!leftVar.getNameSpace().equals(shaderNode.getName())) { + out.write(leftVar.getNameSpace()); + out.write("."); + } + + out.write(leftVar.getName()); + + if (!mapping.getLeftSwizzling().equals("")) { + out.write("."); + out.write(mapping.getLeftSwizzling()); + } + + out.write(" = "); + + if (!rightVar.getNameSpace().equals(shaderNode.getName())) { + out.write(rightVar.getNameSpace()); + out.write("."); + } + + String rightVarName = rightVar.getName(); + if (rightVarName.startsWith("g_") || rightVarName.startsWith("m_")) { + rightVarName = rightVarName.substring(2, rightVarName.length()); + } + + out.write(rightVarName); + + if (!mapping.getRightSwizzling().equals("")) { + out.write("."); + out.write(mapping.getRightSwizzling()); + } + + if (mapping.getCondition() != null) { + out.write(" : "); + out.write(formatCondition(mapping.getCondition(), matParams)); + } + + out.write("\n"); + } + + private void writeValueMapping(final OutputStreamWriter out, final ValueMapping mapping) throws IOException { + + final ShaderNodeVariable variable = mapping.getVariable(); + final String value = mapping.getValue(); + + out.write(" "); + out.write(variable.getName()); + out.write(" = "); + out.write(value); + out.write("\n"); + } + + private String formatCondition(String condition, Collection matParams){ + //condition = condition.replaceAll("defined\\(",""); + + String res = condition; + Pattern pattern = Pattern.compile("defined\\(([A-Z0-9]*)\\)"); + Matcher m = pattern.matcher(condition); + + while(m.find()){ + String match = m.group(0); + String defineName = m.group(1).toLowerCase(); + for (MatParam matParam : matParams) { + if(matParam.getName().toLowerCase().equals(defineName)){ + res = res.replace(match, matParam.getName()); + } + } + } + + return res; + } + + private void writeRenderStateAttribute(OutputStreamWriter out, String name, String value) throws IOException { + out.write(" "); + out.write(name); + out.write(" "); + out.write(value); + out.write("\n"); + } + + private void writeRenderState(RenderState rs, OutputStreamWriter out) throws IOException { + RenderState defRs = RenderState.DEFAULT; + if(rs.getBlendMode() != defRs.getBlendMode()) { + writeRenderStateAttribute(out, "Blend", rs.getBlendMode().name()); + } + if(rs.isWireframe() != defRs.isWireframe()) { + writeRenderStateAttribute(out, "Wireframe", rs.isWireframe()?"On":"Off"); + } + if(rs.getFaceCullMode() != defRs.getFaceCullMode()) { + writeRenderStateAttribute(out, "FaceCull", rs.getFaceCullMode().name()); + } + if(rs.isDepthWrite() != defRs.isDepthWrite()) { + writeRenderStateAttribute(out, "DepthWrite", rs.isDepthWrite()?"On":"Off"); + } + if(rs.isDepthTest() != defRs.isDepthTest()) { + writeRenderStateAttribute(out, "DepthTest", rs.isDepthTest()?"On":"Off"); + } + if(rs.getBlendEquation() != defRs.getBlendEquation()) { + writeRenderStateAttribute(out, "BlendEquation", rs.getBlendEquation().name()); + } + if(rs.getBlendEquationAlpha() != defRs.getBlendEquationAlpha()) { + writeRenderStateAttribute(out, "BlendEquationAlpha", rs.getBlendEquationAlpha().name()); + } + if(rs.getPolyOffsetFactor() != defRs.getPolyOffsetFactor() || rs.getPolyOffsetUnits() != defRs.getPolyOffsetUnits()) { + writeRenderStateAttribute(out, "PolyOffset", rs.getPolyOffsetFactor() + " " + rs.getPolyOffsetUnits()); + } + if(rs.isColorWrite() != defRs.isColorWrite()) { + writeRenderStateAttribute(out, "ColorWrite", rs.isColorWrite()?"On":"Off"); + } + if(rs.getDepthFunc() != defRs.getDepthFunc()) { + writeRenderStateAttribute(out, "DepthFunc", rs.getDepthFunc().name()); + } + if(rs.getLineWidth() != defRs.getLineWidth()) { + writeRenderStateAttribute(out, "LineWidth", Float.toString(rs.getLineWidth())); + } + } + + private String getMatParamNameForDefineId(TechniqueDef techniqueDef, Collection matParams, int defineId) { + for (MatParam matParam : matParams) { + Integer id = techniqueDef.getShaderParamDefineId(matParam.getName()); + if(id !=null && id == defineId){ + return matParam.getName(); + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java b/src/main/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java new file mode 100644 index 0000000..bc40565 --- /dev/null +++ b/src/main/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java @@ -0,0 +1,1123 @@ +/* + * Copyright (c) 2009-2012 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.material.plugins; + +import com.jme3.asset.AssetManager; +import com.jme3.asset.AssetNotFoundException; +import com.jme3.asset.ShaderNodeDefinitionKey; +import com.jme3.material.MatParam; +import com.jme3.material.MaterialDef; +import com.jme3.material.ShaderGenerationInfo; +import com.jme3.material.TechniqueDef; +import com.jme3.shader.*; +import com.jme3.util.blockparser.Statement; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * This class is here to be able to load shaderNodeDefinition from both the + * J3MLoader and ShaderNodeDefinitionLoader. + * + * Also it allows to load the ShaderNodes from a j3md file and build the + * ShaderNodes list of each technique and the ShaderGenerationInfo needed to + * generate shaders + * + * @author Nehon + */ +public class ShaderNodeLoaderDelegate { + + protected Map nodeDefinitions; + protected Map nodes; + protected ShaderNodeDefinition shaderNodeDefinition; + protected ShaderNode shaderNode; + protected TechniqueDef techniqueDef; + protected Map attributes = new HashMap<>(); + protected Map vertexDeclaredUniforms = new HashMap<>(); + protected Map fragmentDeclaredUniforms = new HashMap<>(); + protected Map varyings = new HashMap<>(); + protected MaterialDef materialDef; + protected String shaderLanguage; + protected String shaderName; + protected String varNames = ""; + protected AssetManager assetManager; + protected ConditionParser conditionParser = new ConditionParser(); + protected List nulledConditions = new ArrayList(); + + protected class DeclaredVariable { + + ShaderNodeVariable var; + List nodes = new ArrayList(); + + public DeclaredVariable(ShaderNodeVariable var) { + this.var = var; + } + + public final void addNode(ShaderNode c) { + if (!nodes.contains(c)) { + nodes.add(c); + } + } + } + /** + * Read the ShaderNodesDefinitions block and returns a list of + * ShaderNodesDefinition This method is used by the j3sn loader + * + * note that the order of the definitions in the list is not guaranteed. + * + * @param statements the list statements to parse + * @param key the ShaderNodeDefinitionKey + * @return a list of ShaderNodesDefinition + * @throws IOException + */ + public List readNodesDefinitions(List statements, ShaderNodeDefinitionKey key) throws IOException { + + for (Statement statement : statements) { + String[] split = statement.getLine().split("[ \\{]"); + if (statement.getLine().startsWith("ShaderNodeDefinition")) { + String name = statement.getLine().substring("ShaderNodeDefinition".length()).trim(); + + + if (!getNodeDefinitions().containsKey(name)) { + shaderNodeDefinition = new ShaderNodeDefinition(); + getNodeDefinitions().put(name, shaderNodeDefinition); + shaderNodeDefinition.setName(name); + shaderNodeDefinition.setPath(key.getName()); + readShaderNodeDefinition(statement.getContents(), key); + + } + } else { + throw new MatParseException("ShaderNodeDefinition", split[0], statement); + } + } + + return new ArrayList(getNodeDefinitions().values()); + } + + /** + * Read the ShaderNodesDefinitions block and internally stores a map of + * ShaderNodesDefinition This method is used by the j3m loader. + * + * When loaded in a material, the definitions are not stored as a list, but + * they are stores in Shadernodes based on this definition. + * + * The map is here to map the definition to the nodes, and ovoid reloading + * already loaded definitions + * + * @param statements the list of statements to parse + * @throws IOException + */ + public void readNodesDefinitions(List statements) throws IOException { + readNodesDefinitions(statements, new ShaderNodeDefinitionKey()); + } + + /** + * effectively reads the ShaderNodesDefinitions block + * + * @param statements the list of statements to parse + * @param key the ShaderNodeDefinitionKey + * @throws IOException + */ + protected void readShaderNodeDefinition(List statements, ShaderNodeDefinitionKey key) throws IOException { + boolean isLoadDoc = key instanceof ShaderNodeDefinitionKey && ((ShaderNodeDefinitionKey) key).isLoadDocumentation(); + for (Statement statement : statements) { + try { + String[] split = statement.getLine().split("[ \\{]"); + String line = statement.getLine(); + + if (line.startsWith("Type")) { + String type = line.substring(line.lastIndexOf(':') + 1).trim(); + shaderNodeDefinition.setType(Shader.ShaderType.valueOf(type)); + } else if (line.startsWith("Shader ")) { + readShaderStatement(statement); + shaderNodeDefinition.getShadersLanguage().add(shaderLanguage); + shaderNodeDefinition.getShadersPath().add(shaderName); + } else if (line.startsWith("Documentation")) { + if (isLoadDoc) { + String doc = ""; + for (Statement statement1 : statement.getContents()) { + doc += "\n" + statement1.getLine(); + } + shaderNodeDefinition.setDocumentation(doc); + } + } else if (line.startsWith("Input")) { + varNames = ""; + for (Statement statement1 : statement.getContents()) { + try { + shaderNodeDefinition.getInputs().add(readVariable(statement1)); + } catch (RuntimeException e) { + throw new MatParseException(e.getMessage(), statement1, e); + } + } + } else if (line.startsWith("Output")) { + varNames = ""; + for (Statement statement1 : statement.getContents()) { + try { + if (statement1.getLine().trim().equals("None")) { + shaderNodeDefinition.setNoOutput(true); + } else { + shaderNodeDefinition.getOutputs().add(readVariable(statement1)); + } + } catch (RuntimeException e) { + throw new MatParseException(e.getMessage(), statement1, e); + } + } + } else { + throw new MatParseException("one of Type, Shader, Documentation, Input, Output", split[0], statement); + } + } catch (RuntimeException e) { + throw new MatParseException(e.getMessage(), statement, e); + } + } + } + + /** + * reads a variable declaration statement <glslType> <varName> + * + * @param statement the statement to parse + * @return a ShaderNodeVariable extracted from the statement + * @throws IOException + */ + protected ShaderNodeVariable readVariable(Statement statement) throws IOException { + + String line = statement.getLine().trim().replaceAll("\\s*\\[", "["); + String[] splitVar = line.split("\\s"); + + if (splitVar.length > 3) { + throw new MatParseException("More than 3 arguments", splitVar.length + "", statement); + } + + String defaultValue = splitVar.length > 2? splitVar[2] : null; + String varName = splitVar[1]; + String varType = splitVar[0]; + String multiplicity = null; + + if (varName.contains("[")) { + //we have an array + String[] arr = splitVar[1].split("\\["); + varName = arr[0].trim(); + multiplicity = arr[1].replaceAll("\\]", "").trim(); + } + + if (varNames.contains(varName + ";")) { + throw new MatParseException("Duplicate variable name " + varName, statement); + } + + varNames += varName + ";"; + + final ShaderNodeVariable variable = new ShaderNodeVariable(varType, "", varName, multiplicity); + variable.setDefaultValue(defaultValue); + + return variable; + } + + /** + * reads the VertexShaderNodes{} block + * + * @param statements the list of statements to parse + * @throws IOException + */ + public void readVertexShaderNodes(List statements) throws IOException { + attributes.clear(); + readNodes(statements); + } + + /** + * reads a list of ShaderNode{} blocks + * + * @param statements the list of statements to parse + * @throws IOException + */ + protected void readShaderNode(List statements) throws IOException { + for (Statement statement : statements) { + String line = statement.getLine(); + String[] split = statement.getLine().split("[ \\{]"); + if (line.startsWith("Definition")) { + ShaderNodeDefinition def = findDefinition(statement); + shaderNode.setDefinition(def); + if(def.isNoOutput()){ + techniqueDef.getShaderGenerationInfo().getUnusedNodes().remove(shaderNode.getName()); + } + } else if (line.startsWith("Condition")) { + String condition = line.substring(line.lastIndexOf(":") + 1).trim(); + extractCondition(condition, statement); + shaderNode.setCondition(conditionParser.getFormattedExpression()); + } else if (line.startsWith("InputMappings")) { + for (Statement statement1 : statement.getContents()) { + VariableMapping mapping = readInputMapping(statement1); + techniqueDef.getShaderGenerationInfo().getUnusedNodes().remove(mapping.getRightVariable().getNameSpace()); + shaderNode.getInputMapping().add(mapping); + } + } else if (line.startsWith("OutputMappings")) { + for (Statement statement1 : statement.getContents()) { + VariableMapping mapping = readOutputMapping(statement1); + techniqueDef.getShaderGenerationInfo().getUnusedNodes().remove(shaderNode.getName()); + shaderNode.getOutputMapping().add(mapping); + } + } else if (line.startsWith("ValueMappings")) { + for (final Statement mappingStatement : statement.getContents()) { + final ValueMapping mapping = readValueMapping(mappingStatement); + shaderNode.getValueMapping().add(mapping); + } + } else { + throw new MatParseException("ShaderNodeDefinition", split[0], statement); + } + } + + } + + /** + * reads a mapping statement. Sets the nameSpace, name and swizzling of the + * left variable. Sets the name, nameSpace and swizzling of the right + * variable types will be determined later. + * + * + * Format : .[.] = + * .[.][:Condition] + * + * + * @param statement the statement to read + * @return the read mapping + */ + protected VariableMapping parseMapping(Statement statement, boolean[] hasNameSpace) throws IOException { + VariableMapping mapping = new VariableMapping(); + String[] cond = statement.getLine().split(":"); + + String[] vars = cond[0].split("="); + checkMappingFormat(vars, statement); + ShaderNodeVariable[] variables = new ShaderNodeVariable[2]; + String[] swizzle = new String[2]; + for (int i = 0; i < vars.length; i++) { + String[] expression = vars[i].trim().split("\\."); + if (hasNameSpace[i]) { + if (expression.length <= 3) { + variables[i] = new ShaderNodeVariable("", expression[0].trim(), expression[1].trim()); + } + if (expression.length == 3) { + swizzle[i] = expression[2].trim(); + } + } else { + if (expression.length <= 2) { + variables[i] = new ShaderNodeVariable("", expression[0].trim()); + } + if (expression.length == 2) { + swizzle[i] = expression[1].trim(); + } + } + + } + + mapping.setLeftVariable(variables[0]); + mapping.setLeftSwizzling(swizzle[0] != null ? swizzle[0] : ""); + mapping.setRightVariable(variables[1]); + mapping.setRightSwizzling(swizzle[1] != null ? swizzle[1] : ""); + + if (cond.length > 1) { + extractCondition(cond[1], statement); + mapping.setCondition(conditionParser.getFormattedExpression()); + } + + return mapping; + } + + /** + * Reads a value mapping. + *
+     *  Format : <varName> = <value>
+     * 
+ * + * @param statement the statement to read. + * @return the read mapping + */ + protected ValueMapping parseValueMapping(final Statement statement) throws IOException { + + final String[] vars = statement.getLine().split("="); + + checkMappingFormat(vars, statement); + + final String[] expression = vars[0].trim().split("\\."); + final ShaderNodeVariable variable = new ShaderNodeVariable("", expression[0].trim()); + final String value = vars[1].trim(); + + final ValueMapping mapping = new ValueMapping(); + mapping.setVariable(variable); + mapping.setValue(value); + + return mapping; + } + + /** + * reads the FragmentShaderNodes{} block + * + * @param statements the list of statements to parse + * @throws IOException + */ + public void readFragmentShaderNodes(List statements) throws IOException { + readNodes(statements); + } + + /** + * Reads a Shader statement of this form : + * + * @param statement + * @throws IOException + */ + protected void readShaderStatement(Statement statement) throws IOException { + String[] split = statement.getLine().split(":"); + if (split.length != 2) { + throw new MatParseException("Shader statement syntax incorrect", statement); + } + String[] typeAndLang = split[0].split("\\p{javaWhitespace}+"); + if (typeAndLang.length != 2) { + throw new MatParseException("Shader statement syntax incorrect", statement); + } + shaderName = split[1].trim(); + shaderLanguage = typeAndLang[1]; + } + + /** + * Sets the technique definition currently being loaded + * + * @param techniqueDef the technique def + */ + public void setTechniqueDef(TechniqueDef techniqueDef) { + this.techniqueDef = techniqueDef; + } + + /** + * sets the material def currently being loaded + * + * @param materialDef + */ + public void setMaterialDef(MaterialDef materialDef) { + this.materialDef = materialDef; + } + + /** + * search a variable in the given list and updates its type and namespace + * + * @param var the variable to update + * @param list the variables list + * @return true if the variable has been found and updated + */ + protected boolean updateVariableFromList(ShaderNodeVariable var, List list) { + for (ShaderNodeVariable shaderNodeVariable : list) { + if (shaderNodeVariable.getName().equals(var.getName())) { + var.setType(shaderNodeVariable.getType()); + var.setMultiplicity(shaderNodeVariable.getMultiplicity()); + var.setNameSpace(shaderNode.getName()); + return true; + } + } + return false; + } + + /** + * updates the type of the right variable of a mapping from the type of the + * left variable + * + * @param mapping the mapping to consider + */ + protected void updateRightTypeFromLeftType(VariableMapping mapping) { + String type = mapping.getLeftVariable().getType(); + int card = ShaderUtils.getCardinality(type, mapping.getRightSwizzling()); + if (card > 0) { + if (card == 1) { + type = "float"; + } else { + type = "vec" + card; + } + } + mapping.getRightVariable().setType(type); + } + + /** + * check if once a mapping expression is split by "=" the resulting array + * have 2 elements + * + * @param vars the array + * @param statement the statement + * @throws IOException + */ + protected void checkMappingFormat(String[] vars, Statement statement) throws IOException { + if (vars.length != 2) { + throw new MatParseException("Not a valid expression should be '[.] = .[.][:Condition]'", statement); + } + } + + /** + * finds a MatParam in the materialDef from the given name + * + * @param varName the matparam name + * @return the MatParam + */ + protected MatParam findMatParam(String varName) { + for (MatParam matParam : materialDef.getMaterialParams()) { + if (varName.equals(matParam.getName())) { + return matParam; + } + } + return null; + } + + /** + * finds an UniformBinding representing a WorldParam from the techniqueDef + * + * @param varName the name of the WorldParam + * @return the corresponding UniformBinding to the WorldParam + */ + protected UniformBinding findWorldParam(String varName) { + for (UniformBinding worldParam : techniqueDef.getWorldBindings()) { + if (varName.equals(worldParam.toString())) { + return worldParam; + } + } + return null; + } + + /** + * updates the right variable of the given mapping from a UniformBinding (a + * WorldParam) it checks if the uniform hasn't already been loaded, add it + * to the maps if not. + * + * @param param the WorldParam UniformBinding + * @param mapping the mapping + * @param map the map of uniforms to search into + * @return true if the param was added to the map + */ + protected boolean updateRightFromUniforms(UniformBinding param, VariableMapping mapping, Map map) { + ShaderNodeVariable right = mapping.getRightVariable(); + String name = param.toString(); + + DeclaredVariable dv = map.get(name); + if (dv == null) { + right.setType(param.getGlslType()); + right.setName(name); + right.setPrefix("g_"); + dv = new DeclaredVariable(right); + map.put(right.getName(), dv); + dv.addNode(shaderNode); + mapping.setRightVariable(right); + return true; + } + dv.addNode(shaderNode); + mapping.setRightVariable(dv.var); + return false; + } + + /** + * updates the right variable of the given mapping from a MatParam (a + * WorldParam) it checks if the uniform hasn't already been loaded, add it + * to the maps if not. + * + * @param param the MatParam + * @param mapping the mapping + * @param map the map of uniforms to search into + * @return true if the param was added to the map + */ + public boolean updateRightFromUniforms(MatParam param, VariableMapping mapping, Map map, Statement statement) throws MatParseException { + ShaderNodeVariable right = mapping.getRightVariable(); + DeclaredVariable dv = map.get(param.getName()); + if (dv == null) { + right.setType(param.getVarType().getGlslType()); + right.setName(param.getName()); + right.setPrefix("m_"); + if(mapping.getLeftVariable().getMultiplicity() != null){ + if(!param.getVarType().name().endsWith("Array")){ + throw new MatParseException(param.getName() + " is not of Array type", statement); + } + String multiplicity = mapping.getLeftVariable().getMultiplicity(); + try { + Integer.parseInt(multiplicity); + } catch (NumberFormatException nfe) { + //multiplicity is not an int attempting to find for a material parameter. + MatParam mp = findMatParam(multiplicity); + if (mp != null) { + //It's tied to a material param, let's create a define and use this as the multiplicity + addDefine(multiplicity, VarType.Int); + multiplicity = multiplicity.toUpperCase(); + mapping.getLeftVariable().setMultiplicity(multiplicity); + //only declare the variable if the define is defined. + mapping.getLeftVariable().setCondition(mergeConditions(mapping.getLeftVariable().getCondition(), "defined(" + multiplicity + ")", "||")); + } else { + throw new MatParseException("Wrong multiplicity for variable" + mapping.getLeftVariable().getName() + ". " + multiplicity + " should be an int or a declared material parameter.", statement); + } + } + //the right variable must have the same multiplicity and the same condition. + right.setMultiplicity(multiplicity); + right.setCondition(mapping.getLeftVariable().getCondition()); + } + dv = new DeclaredVariable(right); + map.put(right.getName(), dv); + dv.addNode(shaderNode); + mapping.setRightVariable(right); + return true; + } + dv.addNode(shaderNode); + mapping.setRightVariable(dv.var); + return false; + } + + /** + * updates a variable from the Attribute list + * + * @param right the variable + * @param mapping the mapping + */ + public void updateVarFromAttributes(ShaderNodeVariable right, VariableMapping mapping) { + DeclaredVariable dv = attributes.get(right.getName()); + if (dv == null) { + dv = new DeclaredVariable(right); + attributes.put(right.getName(), dv); + updateRightTypeFromLeftType(mapping); + } else { + mapping.setRightVariable(dv.var); + } + dv.addNode(shaderNode); + } + + /** + * Adds a define to the technique def + * + * @param paramName + */ + public void addDefine(String paramName, VarType paramType) { + if (techniqueDef.getShaderParamDefine(paramName) == null) { + techniqueDef.addShaderParamDefine(paramName, paramType, paramName.toUpperCase()); + } + } + + /** + * find a variable with the given name from the list of variable + * + * @param vars a list of shaderNodeVariables + * @param rightVarName the variable name to search for + * @return the found variable or null is not found + */ + public ShaderNodeVariable findNodeOutput(List vars, String rightVarName) { + ShaderNodeVariable var = null; + for (ShaderNodeVariable variable : vars) { + if (variable.getName().equals(rightVarName)) { + var = variable; + } + } + return var; + } + + /** + * extract and check a condition expression + * + * @param cond the condition expression + * @param statement the statement being read + * @throws IOException + */ + public void extractCondition(String cond, Statement statement) throws IOException { + List defines = conditionParser.extractDefines(cond); + for (String string : defines) { + MatParam param = findMatParam(string); + if (param != null) { + addDefine(param.getName(), param.getVarType()); + } else { + throw new MatParseException("Invalid condition, condition must match a Material Parameter named " + cond, statement); + } + } + } + + /** + * reads an input mapping + * + * @param statement1 the statement being read + * @return the mapping + * @throws IOException + */ + public VariableMapping readInputMapping(Statement statement1) throws IOException { + VariableMapping mapping = null; + try { + mapping = parseMapping(statement1, new boolean[]{false, true}); + } catch (Exception e) { + throw new MatParseException("Unexpected mapping format", statement1, e); + } + ShaderNodeVariable left = mapping.getLeftVariable(); + ShaderNodeVariable right = mapping.getRightVariable(); + if (!updateVariableFromList(left, shaderNode.getDefinition().getInputs())) { + throw new MatParseException(left.getName() + " is not an input variable of " + shaderNode.getDefinition().getName(), statement1); + } + + if (left.getType().startsWith("sampler") && !right.getNameSpace().equals("MatParam")) { + throw new MatParseException("Samplers can only be assigned to MatParams", statement1); + } + + if (right.getNameSpace().equals("Global")) { + right.setType("vec4");//Globals are all vec4 for now (maybe forever...) + storeGlobal(right, statement1); + + } else if (right.getNameSpace().equals("Attr")) { + if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) { + throw new MatParseException("Cannot have an attribute as input in a fragment shader" + right.getName(), statement1); + } + updateVarFromAttributes(mapping.getRightVariable(), mapping); + storeAttribute(mapping.getRightVariable()); + } else if (right.getNameSpace().equals("MatParam")) { + MatParam param = findMatParam(right.getName()); + if (param == null) { + throw new MatParseException("Could not find a Material Parameter named " + right.getName(), statement1); + } + if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { + if (updateRightFromUniforms(param, mapping, vertexDeclaredUniforms, statement1)) { + updateMaterialTextureType(statement1, mapping, left, param); + storeVertexUniform(mapping.getRightVariable()); + } + } else { + if (updateRightFromUniforms(param, mapping, fragmentDeclaredUniforms, statement1)) { + updateMaterialTextureType(statement1, mapping, left, param); + storeFragmentUniform(mapping.getRightVariable()); + } + } + + } else if (right.getNameSpace().equals("WorldParam")) { + UniformBinding worldParam = findWorldParam(right.getName()); + if (worldParam == null) { + throw new MatParseException("Could not find a World Parameter named " + right.getName(), statement1); + } + if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { + if (updateRightFromUniforms(worldParam, mapping, vertexDeclaredUniforms)) { + storeVertexUniform(mapping.getRightVariable()); + } + } else { + if (updateRightFromUniforms(worldParam, mapping, fragmentDeclaredUniforms)) { + storeFragmentUniform(mapping.getRightVariable()); + } + } + + } else { + ShaderNode node = nodes.get(right.getNameSpace()); + if (node == null) { + throw new MatParseException("Undeclared node" + right.getNameSpace() + ". Make sure this node is declared before the current node", statement1); + } + ShaderNodeVariable var = findNodeOutput(node.getDefinition().getOutputs(), right.getName()); + if (var == null) { + throw new MatParseException("Cannot find output variable" + right.getName() + " form ShaderNode " + node.getName(), statement1); + } + right.setNameSpace(node.getName()); + right.setType(var.getType()); + right.setMultiplicity(var.getMultiplicity()); + mapping.setRightVariable(right); + storeVaryings(node, mapping.getRightVariable()); + + } + + checkTypes(mapping, statement1); + + return mapping; + } + + /** + * Updated the material texture type of the variable mapping. + * + * @param statement the statement. + * @param mapping the variable mapping. + * @param left the left variable. + * @param param the material parameter. + * @throws MatParseException + */ + private void updateMaterialTextureType(final Statement statement, final VariableMapping mapping, + final ShaderNodeVariable left, final MatParam param) throws MatParseException { + + if (!mapping.getRightVariable().getType().contains("|")) { + return; + } + + final String type = fixSamplerType(left.getType(), mapping.getRightVariable().getType()); + + if (type != null) { + mapping.getRightVariable().setType(type); + } else { + throw new MatParseException(param.getVarType().toString() + " can only be matched to one of " + + param.getVarType().getGlslType().replaceAll("\\|", ",") + " found " + left.getType(), statement); + } + } + + /** + * reads an output mapping + * + * @param statement1 the statement being read + * @return the mapping + * @throws IOException + */ + public VariableMapping readOutputMapping(Statement statement1) throws IOException { + VariableMapping mapping = null; + try { + mapping = parseMapping(statement1, new boolean[]{true, false}); + } catch (Exception e) { + throw new MatParseException("Unexpected mapping format", statement1, e); + } + ShaderNodeVariable left = mapping.getLeftVariable(); + ShaderNodeVariable right = mapping.getRightVariable(); + + + if (left.getType().startsWith("sampler") || right.getType().startsWith("sampler")) { + throw new MatParseException("Samplers can only be inputs", statement1); + } + + if (left.getNameSpace().equals("Global")) { + left.setType("vec4");//Globals are all vec4 for now (maybe forever...) + storeGlobal(left, statement1); + } else { + throw new MatParseException("Only Global nameSpace is allowed for outputMapping, got" + left.getNameSpace(), statement1); + } + + if (!updateVariableFromList(right, shaderNode.getDefinition().getOutputs())) { + throw new MatParseException(right.getName() + " is not an output variable of " + shaderNode.getDefinition().getName(), statement1); + } + + checkTypes(mapping, statement1); + + return mapping; + } + + /** + * Reads a value mapping. + * + * @param statement the statement to read. + * @return the value mapping. + * @throws IOException + */ + public ValueMapping readValueMapping(final Statement statement) throws IOException { + + ValueMapping mapping; + try { + mapping = parseValueMapping(statement); + } catch (final Exception e) { + throw new MatParseException("Unexpected mapping format", statement, e); + } + + final ShaderNodeVariable variable = mapping.getVariable(); + final ShaderNodeDefinition definition = shaderNode.getDefinition(); + + if (!updateVariableFromList(variable, definition.getInputs())) { + throw new MatParseException(variable.getName() + " is not an input variable of " + + definition.getName(), statement); + } + + return mapping; + } + + /** + * Reads a list of ShaderNodes + * + * @param statements the list of statements to read + * @throws IOException + */ + public void readNodes(List statements) throws IOException { + if (techniqueDef.getShaderNodes() == null) { + techniqueDef.setShaderNodes(new ArrayList()); + techniqueDef.setShaderGenerationInfo(new ShaderGenerationInfo()); + } + + for (Statement statement : statements) { + String[] split = statement.getLine().split("[ \\{]"); + if (statement.getLine().startsWith("ShaderNode ")) { + String name = statement.getLine().substring("ShaderNode".length()).trim(); + if (nodes == null) { + nodes = new HashMap(); + } + if (!nodes.containsKey(name)) { + shaderNode = new ShaderNode(); + shaderNode.setName(name); + techniqueDef.getShaderGenerationInfo().getUnusedNodes().add(name); + readShaderNode(statement.getContents()); + nodes.put(name, shaderNode); + techniqueDef.getShaderNodes().add(shaderNode); + } else { + throw new MatParseException("ShaderNode " + name + " is already defined", statement); + } + + } else { + throw new MatParseException("ShaderNode", split[0], statement); + } + } + } + + /** + * retrieve the leftType corresponding sampler type from the rightType + * + * @param leftType the left samplerType + * @param rightType the right sampler type (can be multiple types separated + * by "|" + * @return the type or null if not found + */ + public String fixSamplerType(String leftType, String rightType) { + String[] types = rightType.split("\\|"); + for (String string : types) { + if (leftType.equals(string)) { + return string; + } + } + return null; + } + + /** + * stores a global output + * + * @param var the variable to store + * @param statement1 the statement being read + * @throws IOException + */ + public void storeGlobal(ShaderNodeVariable var, Statement statement1) throws IOException { + var.setShaderOutput(true); + if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { + ShaderNodeVariable global = techniqueDef.getShaderGenerationInfo().getVertexGlobal(); + if (global != null) { + if (!global.getName().equals(var.getName())) { + throw new MatParseException("A global output is already defined for the vertex shader: " + global.getName() + ". vertex shader can only have one global output", statement1); + } + } else { + techniqueDef.getShaderGenerationInfo().setVertexGlobal(var); + } + } else if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) { + storeVariable(var, techniqueDef.getShaderGenerationInfo().getFragmentGlobals()); + } + } + + /** + * store an attribute + * + * @param var the variable to store + */ + public void storeAttribute(ShaderNodeVariable var) { + storeVariable(var, techniqueDef.getShaderGenerationInfo().getAttributes()); + } + + /** + * store a vertex uniform + * + * @param var the variable to store + */ + public void storeVertexUniform(ShaderNodeVariable var) { + storeVariable(var, techniqueDef.getShaderGenerationInfo().getVertexUniforms()); + + } + + /** + * store a fragment uniform + * + * @param var the variable to store + */ + public void storeFragmentUniform(ShaderNodeVariable var) { + storeVariable(var, techniqueDef.getShaderGenerationInfo().getFragmentUniforms()); + + } + + /** + * sets the assetManager + * + * @param assetManager + */ + public void setAssetManager(AssetManager assetManager) { + this.assetManager = assetManager; + } + + /** + * Find the definition from this statement (loads it if necessary) + * + * @param statement the statement being read + * @return the definition + * @throws IOException + */ + public ShaderNodeDefinition findDefinition(Statement statement) throws IOException { + + final String defLine[] = statement.getLine().split(":"); + + if (defLine.length != 3) { + throw new MatParseException("Can't find shader node definition for: ", statement); + } + + final Map nodeDefinitions = getNodeDefinitions(); + final String definitionName = defLine[1].trim(); + final String definitionPath = defLine[2].trim(); + final String fullName = definitionName + ":" + definitionPath; + + ShaderNodeDefinition def = nodeDefinitions.get(fullName); + if (def != null) { + return def; + } + + List defs; + try { + defs = assetManager.loadAsset(new ShaderNodeDefinitionKey(definitionPath)); + } catch (final AssetNotFoundException e) { + throw new MatParseException("Couldn't find " + definitionPath, statement, e); + } + + for (final ShaderNodeDefinition definition : defs) { + if (definitionName.equals(definition.getName())) { + def = definition; + } + final String key = definition.getName() + ":" + definitionPath; + if (!(nodeDefinitions.containsKey(key))) { + nodeDefinitions.put(key, definition); + } + } + + if (def == null) { + throw new MatParseException(definitionName + " is not a declared as Shader Node Definition", statement); + } + + return def; + } + + /** + * store a varying + * + * @param node the shaderNode + * @param variable the variable to store + */ + public void storeVaryings(ShaderNode node, ShaderNodeVariable variable) { + variable.setShaderOutput(true); + + final ShaderNodeDefinition nodeDefinition = node.getDefinition(); + final ShaderNodeDefinition currentDefinition = shaderNode.getDefinition(); + + if (nodeDefinition.getType() != Shader.ShaderType.Vertex || + currentDefinition.getType() != Shader.ShaderType.Fragment) { + return; + } + + final String fullName = node.getName() + "." + variable.getName(); + + DeclaredVariable declaredVar = varyings.get(fullName); + + if (declaredVar == null) { + techniqueDef.getShaderGenerationInfo().getVaryings().add(variable); + declaredVar = new DeclaredVariable(variable); + varyings.put(fullName, declaredVar); + } + + declaredVar.addNode(shaderNode); + + // if a variable is declared with the same name as an input and an output and is a varying, + // set it as a shader output so it's declared as a varying only once. + for (final VariableMapping variableMapping : node.getInputMapping()) { + final ShaderNodeVariable leftVariable = variableMapping.getLeftVariable(); + if (leftVariable.getName().equals(variable.getName())) { + leftVariable.setShaderOutput(true); + } + } + } + + /** + * merges 2 condition with the given operator + * + * @param condition1 the first condition + * @param condition2 the second condition + * @param operator the operator ("&&" or "||&) + * @return the merged condition + */ + public String mergeConditions(String condition1, String condition2, String operator) { + if (condition1 != null) { + if (condition2 == null) { + return condition1; + } else { + String mergedCondition = "(" + condition1 + ") " + operator + " (" + condition2 + ")"; + return mergedCondition; + } + } else { + return condition2; + } + } + + /** + * search a variable in a list from its name and merge the conditions of the + * variables + * + * @param variable the variable + * @param varList the variable list + */ + public void storeVariable(ShaderNodeVariable variable, List varList) { + for (ShaderNodeVariable var : varList) { + if (var.getName().equals(variable.getName())) { + return; + } + } + varList.add(variable); + } + + /** + * check the types of a mapping, left type must match right type take the + * swizzle into account + * + * @param mapping the mapping + * @param statement1 the statement being read + * @throws MatParseException + */ + protected void checkTypes(VariableMapping mapping, Statement statement1) throws MatParseException { + if (!ShaderUtils.typesMatch(mapping)) { + String ls = mapping.getLeftSwizzling().length() == 0 ? "" : "." + mapping.getLeftSwizzling(); + String rs = mapping.getRightSwizzling().length() == 0 ? "" : "." + mapping.getRightSwizzling(); + throw new MatParseException("Type mismatch, cannot convert " + mapping.getRightVariable().getType() + rs + " to " + mapping.getLeftVariable().getType() + ls, statement1); + } + if (!ShaderUtils.multiplicityMatch(mapping)) { + String type1 = mapping.getLeftVariable().getType() + "[" + mapping.getLeftVariable().getMultiplicity() + "]"; + String type2 = mapping.getRightVariable().getType() + "[" + mapping.getRightVariable().getMultiplicity() + "]"; + throw new MatParseException("Type mismatch, cannot convert " + type1 + " to " + type2, statement1); + } + } + + private Map getNodeDefinitions() { + if (nodeDefinitions == null) { + nodeDefinitions = new HashMap<>(); + } + return nodeDefinitions; + } + + + public void clear() { + nodeDefinitions.clear(); + nodes.clear(); + shaderNodeDefinition = null; + shaderNode = null; + techniqueDef = null; + attributes.clear(); + vertexDeclaredUniforms.clear(); + fragmentDeclaredUniforms.clear(); + varyings.clear(); + materialDef = null; + shaderLanguage = ""; + shaderName = ""; + varNames = ""; + assetManager = null; + nulledConditions.clear(); + } +} diff --git a/src/main/java/com/jme3/shader/ShaderNode.java b/src/main/java/com/jme3/shader/ShaderNode.java new file mode 100644 index 0000000..dbe0e60 --- /dev/null +++ b/src/main/java/com/jme3/shader/ShaderNode.java @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2009-2012 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.shader; + +import com.jme3.export.*; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * A ShaderNode is the unit brick part of a shader program. A shader can be + * describe with several shader nodes that are plugged together through inputs + * and outputs. + * + * A ShaderNode is based on a definition that has a shader code, inputs and + * output variables. This node can be activated based on a condition, and has + * input and output mapping. + * + * This class is not intended to be used by JME users directly. It's the + * structure for loading shader nodes from a J3md material definition file + * + * @author Nehon + */ +public class ShaderNode implements Savable, Cloneable { + + private String name; + private ShaderNodeDefinition definition; + private String condition; + + private List inputMapping = new ArrayList<>(); + private List outputMapping = new ArrayList<>(); + + /** + * The mapping with values of some input variables. + */ + private List valueMapping = new ArrayList<>(); + + /** + * creates a ShaderNode + * + * @param name the name + * @param definition the ShaderNodeDefinition + * @param condition the condition to activate this node + */ + public ShaderNode(String name, ShaderNodeDefinition definition, String condition) { + this.name = name; + this.definition = definition; + this.condition = condition; + } + + /** + * creates a ShaderNode + */ + public ShaderNode() { + } + + /** + * + * @return the name of the node + */ + public String getName() { + return name; + } + + /** + * sets the name of th node + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * returns the definition + * + * @return the ShaderNodeDefinition + */ + public ShaderNodeDefinition getDefinition() { + return definition; + } + + /** + * sets the definition + * + * @param definition the ShaderNodeDefinition + */ + public void setDefinition(ShaderNodeDefinition definition) { + this.definition = definition; + } + + /** + * + * @return the condition + */ + public String getCondition() { + return condition; + } + + /** + * sets the condition + * + * @param condition the condition + */ + public void setCondition(String condition) { + this.condition = condition; + } + + /** + * return a list of VariableMapping representing the input mappings of this + * node + * + * @return the input mappings + */ + public List getInputMapping() { + return inputMapping; + } + + /** + * sets the input mappings + * + * @param inputMapping the input mappings + */ + public void setInputMapping(List inputMapping) { + this.inputMapping = inputMapping; + } + + /** + * return a list of VariableMapping representing the output mappings of this + * node + * + * @return the output mappings + */ + public List getOutputMapping() { + return outputMapping; + } + + /** + * sets the output mappings + * + * @param outputMapping the output mappings + */ + public void setOutputMapping(List outputMapping) { + this.outputMapping = outputMapping; + } + + /** + * Gets the value mapping. + * + * @return the value mapping. + */ + public List getValueMapping() { + return valueMapping; + } + + /** + * Sets the value mapping. + * + * @param valueMapping the value mapping. + */ + public void setValueMapping(final List valueMapping) { + this.valueMapping = valueMapping; + } + + /** + * jme serialization + * + * @param ex the exporter + * @throws IOException + */ + @Override + public void write(JmeExporter ex) throws IOException { + OutputCapsule oc = ex.getCapsule(this); + oc.write(name, "name", ""); + oc.write(definition, "definition", null); + oc.write(condition, "condition", null); + oc.writeSavableArrayList((ArrayList) inputMapping, "inputMapping", new ArrayList()); + oc.writeSavableArrayList((ArrayList) outputMapping, "outputMapping", new ArrayList()); + oc.writeSavableArrayList((ArrayList) valueMapping, "valueMapping", new ArrayList()); + } + + /** + * jme serialization + * + * @param im the importer + * @throws IOException + */ + @Override + public void read(JmeImporter im) throws IOException { + InputCapsule ic = im.getCapsule(this); + name = ic.readString("name", ""); + definition = (ShaderNodeDefinition) ic.readSavable("definition", null); + condition = ic.readString("condition", null); + inputMapping = (List) ic.readSavableArrayList("inputMapping", new ArrayList()); + outputMapping = (List) ic.readSavableArrayList("outputMapping", new ArrayList()); + valueMapping = (List) ic.readSavableArrayList("valueMapping", new ArrayList()); + } + + /** + * convenience tostring + * + * @return a string + */ + @Override + public String toString() { + + final StringBuilder builder = new StringBuilder("ShaderNode:"); + builder.append("\n\tname=").append(name) + .append("\n\tdefinition=").append(definition.getName()) + .append("\n\tcondition=").append(condition); + + if (!inputMapping.isEmpty()) { + builder.append("\n\tinputMapping:\n"); + for (final VariableMapping mapping : inputMapping) { + builder.append("\t\t").append(mapping).append('\n'); + } + } + + if (!outputMapping.isEmpty()) { + builder.append("\n\toutputMapping:\n"); + for (final VariableMapping mapping : outputMapping) { + builder.append("\t\t").append(mapping).append('\n'); + } + } + + if (!valueMapping.isEmpty()) { + builder.append("\n\tvalueMapping:\n"); + for (final ValueMapping mapping : valueMapping) { + builder.append("\t\t").append(mapping).append('\n'); + } + } + + if (builder.charAt(builder.length() - 1) == '\n') { + builder.delete(builder.length() - 1, builder.length()); + } + + return builder.toString(); + } + + @Override + public ShaderNode clone() throws CloneNotSupportedException { + ShaderNode clone = (ShaderNode) super.clone(); + + // No need to clone the definition. + clone.definition = definition; + + clone.inputMapping = new ArrayList<>(); + for (VariableMapping variableMapping : inputMapping) { + clone.inputMapping.add(variableMapping.clone()); + } + + clone.outputMapping = new ArrayList<>(); + for (VariableMapping variableMapping : outputMapping) { + clone.outputMapping.add(variableMapping.clone()); + } + + clone.valueMapping = new ArrayList<>(); + for (final ValueMapping valueMapping : valueMapping) { + clone.valueMapping.add(valueMapping.clone()); + } + + return clone; + } +} diff --git a/src/main/java/com/jme3/shader/ShaderNodeVariable.java b/src/main/java/com/jme3/shader/ShaderNodeVariable.java new file mode 100644 index 0000000..bbb0761 --- /dev/null +++ b/src/main/java/com/jme3/shader/ShaderNodeVariable.java @@ -0,0 +1,343 @@ +/* + * Copyright (c) 2009-2012 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.shader; + +import com.jme3.export.InputCapsule; +import com.jme3.export.JmeExporter; +import com.jme3.export.JmeImporter; +import com.jme3.export.OutputCapsule; +import com.jme3.export.Savable; +import java.io.IOException; + +/** + * A shader node variable + * + * @author Nehon + */ +public class ShaderNodeVariable implements Savable, Cloneable { + + private String prefix = ""; + private String name; + private String type; + private String nameSpace; + private String condition; + private String multiplicity; + private String defaultValue; + + private boolean shaderOutput = false; + + /** + * creates a ShaderNodeVariable + * + * @param type the glsl type of the variable + * @param name the name of the variable + */ + public ShaderNodeVariable(String type, String name) { + this.name = name; + this.type = type; + } + + /** + * creates a ShaderNodeVariable + * + * @param type the glsl type of the variable + * @param nameSpace the nameSpace (can be the name of the shaderNode or + * Global,Attr,MatParam,WorldParam) + * @param name the name of the variable + * @param multiplicity the number of element if this variable is an array. Can be an Int of a declared material parameter + */ + public ShaderNodeVariable(String type, String nameSpace, String name, String multiplicity) { + this.name = name; + this.nameSpace = nameSpace; + this.type = type; + this.multiplicity = multiplicity; + } + + + /** + * creates a ShaderNodeVariable + * + * @param type the glsl type of the variable + * @param nameSpace the nameSpace (can be the name of the shaderNode or + * Global,Attr,MatParam,WorldParam) + * @param name the name of the variable + * @param multiplicity the number of element if this variable is an array. Can be an Int of a declared material parameter + * @param prefix the variable prefix to append at generation times. This is mostly to add the g_ and m_ for uniforms + */ + public ShaderNodeVariable(String type, String nameSpace, String name, String multiplicity, String prefix) { + this(type, nameSpace, name, multiplicity); + this.prefix = prefix; + } + + /** + * creates a ShaderNodeVariable + * + * @param type the glsl type of the variable + * @param nameSpace the nameSpace (can be the name of the shaderNode or + * Global,Attr,MatParam,WorldParam) + * @param name the name of the variable + */ + public ShaderNodeVariable(String type, String nameSpace, String name) { + this.name = name; + this.nameSpace = nameSpace; + this.type = type; + } + + /** + * returns the name + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * sets the name + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * + * @return the glsl type + */ + public String getType() { + return type; + } + + /** + * sets the glsl type + * + * @param type the type + */ + public void setType(String type) { + this.type = type; + } + + /** + * + * @return the name space (can be the name of the shaderNode or + * Global,Attr,MatParam,WorldParam) + */ + public String getNameSpace() { + return nameSpace; + } + + /** + * @return the variable prefix + */ + public String getPrefix() { + return prefix; + } + + /** + * Sets the variable prefix (m_ or g_) + * + * @param prefix + */ + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + /** + * sets the nameSpace (can be the name of the shaderNode or + * Global,Attr,MatParam,WorldParam) + * + * @param nameSpace + */ + public void setNameSpace(String nameSpace) { + this.nameSpace = nameSpace; + } + + /** + * Gets the default value of this variable. + * + * @return the default value of this variable. + */ + public String getDefaultValue() { + return defaultValue; + } + + /** + * Sets the default value of this variable. + * + * @param defaultValue the default value of this variable. + */ + public void setDefaultValue(final String defaultValue) { + this.defaultValue = defaultValue; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 29 * hash + (name != null?name.hashCode():0); + hash = 29 * hash + (type != null?type.hashCode():0); + hash = 29 * hash + (prefix != null ? prefix.hashCode() : 0); + hash = 29 * hash + (nameSpace != null?nameSpace.hashCode():0); + hash = 29 * hash + (condition != null?condition.hashCode():0); + hash = 29 * hash + (multiplicity != null?multiplicity.hashCode():0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ShaderNodeVariable other = (ShaderNodeVariable) obj; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.type == null) ? (other.type != null) : !this.type.equals(other.type)) { + return false; + } + if ((this.prefix == null) ? (other.prefix != null) : !this.prefix.equals(other.prefix)) { + return false; + } + if ((this.nameSpace == null) ? (other.nameSpace != null) : !this.nameSpace.equals(other.nameSpace)) { + return false; + } + if ((this.condition == null) ? (other.condition != null) : !this.condition.equals(other.condition)) { + return false; + } + if ((this.multiplicity == null) ? (other.multiplicity != null) : !this.multiplicity.equals(other.multiplicity)) { + return false; + } + return true; + } + + /** + * jme serialization (not used) + * + * @param ex the exporter + * @throws IOException + */ + @Override + public void write(JmeExporter ex) throws IOException { + OutputCapsule oc = ex.getCapsule(this); + oc.write(name, "name", ""); + oc.write(type, "type", ""); + oc.write(prefix, "prefix", ""); + oc.write(nameSpace, "nameSpace", ""); + oc.write(condition, "condition", null); + oc.write(shaderOutput, "shaderOutput", false); + oc.write(multiplicity, "multiplicity", null); + oc.write(defaultValue, "defaultValue", null); + } + + /** + * jme serialization (not used) + * + * @param im the importer + * @throws IOException + */ + @Override + public void read(JmeImporter im) throws IOException { + InputCapsule ic = im.getCapsule(this); + name = ic.readString("name", ""); + type = ic.readString("type", ""); + prefix = ic.readString("pefix", ""); + nameSpace = ic.readString("nameSpace", ""); + condition = ic.readString("condition", null); + shaderOutput = ic.readBoolean("shaderOutput", false); + multiplicity = ic.readString("multiplicity", null); + defaultValue = ic.readString("defaultValue", null); + } + + /** + * + * @return the condition for this variable to be declared + */ + public String getCondition() { + return condition; + } + + /** + * sets the condition + * + * @param condition the condition + */ + public void setCondition(String condition) { + this.condition = condition; + } + + @Override + public String toString() { + return type + ' ' + (nameSpace != null ? (nameSpace + '.') : "") + name; + } + + /** + * + * @return true if this variable is a shader output + */ + public boolean isShaderOutput() { + return shaderOutput; + } + + /** + * sets to true if this variable is a shader output + * + * @param shaderOutput true if this variable is a shader output + */ + public void setShaderOutput(boolean shaderOutput) { + this.shaderOutput = shaderOutput; + } + + /** + * + * @return the number of elements if this variable is an array + */ + public String getMultiplicity() { + return multiplicity; + } + + /** + * sets the number of elements of this variable making it an array + * this value can be a number of can be a define + * @param multiplicity + */ + public void setMultiplicity(String multiplicity) { + this.multiplicity = multiplicity; + } + + @Override + public ShaderNodeVariable clone() throws CloneNotSupportedException { + return (ShaderNodeVariable) super.clone(); + } +} diff --git a/src/main/java/com/jme3/shader/ValueMapping.java b/src/main/java/com/jme3/shader/ValueMapping.java new file mode 100644 index 0000000..c89a5c3 --- /dev/null +++ b/src/main/java/com/jme3/shader/ValueMapping.java @@ -0,0 +1,97 @@ +package com.jme3.shader; + +import com.jme3.export.*; + +import java.io.IOException; + +/** + * The mapping to define values of some input variables. + * + * @author JavaSaBr + */ +public class ValueMapping implements Savable, Cloneable { + + /** + * The variable. + */ + private ShaderNodeVariable variable; + + /** + * The value. + */ + private String value; + + public ValueMapping() { + } + + public ValueMapping(final ShaderNodeVariable variable) { + this.variable = variable; + } + + public ValueMapping(final ShaderNodeVariable variable, final String value) { + this.variable = variable; + this.value = value; + } + + /** + * Gets the variable. + * + * @return the variable. + */ + public ShaderNodeVariable getVariable() { + return variable; + } + + /** + * Sets the variable. + * + * @param variable the variable. + */ + public void setVariable(final ShaderNodeVariable variable) { + this.variable = variable; + } + + /** + * Sets the value. + * + * @param value the value. + */ + public void setValue(final String value) { + this.value = value; + } + + /** + * Gets the value. + * + * @return the value. + */ + public String getValue() { + return value; + } + + @Override + public ValueMapping clone() throws CloneNotSupportedException { + final ValueMapping clone = (ValueMapping) super.clone(); + clone.variable = variable == null ? null : variable.clone(); + return clone; + } + + @Override + public void write(final JmeExporter ex) throws IOException { + final OutputCapsule oc = ex.getCapsule(this); + oc.write(variable, "variable", null); + oc.write(value, "value", null); + } + + @Override + public void read(final JmeImporter im) throws IOException { + final InputCapsule ic = im.getCapsule(this); + variable = (ShaderNodeVariable) ic.readSavable("", null); + value = ic.readString("value", null); + } + + @Override + public String toString() { + return variable + " = '" + value + '\''; + } +} diff --git a/src/main/java/com/jme3/shader/VariableMapping.java b/src/main/java/com/jme3/shader/VariableMapping.java new file mode 100644 index 0000000..eb287e6 --- /dev/null +++ b/src/main/java/com/jme3/shader/VariableMapping.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2009-2012 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.shader; + +import com.jme3.export.*; + +import java.io.IOException; + +/** + * represents a mapping between 2 ShaderNodeVariables + * + * @author Nehon + */ +public class VariableMapping implements Savable, Cloneable { + + private ShaderNodeVariable leftVariable; + private ShaderNodeVariable rightVariable; + private String condition; + private String leftSwizzling = ""; + private String rightSwizzling = ""; + + /** + * creates a VariableMapping + */ + public VariableMapping() { + } + + /** + * creates a VariableMapping + * + * @param leftVariable the left hand side variable of the expression + * @param leftSwizzling the swizzling of the left variable + * @param rightVariable the right hand side variable of the expression + * @param rightSwizzling the swizzling of the right variable + * @param condition the condition for this mapping + */ + public VariableMapping(ShaderNodeVariable leftVariable, String leftSwizzling, ShaderNodeVariable rightVariable, String rightSwizzling, String condition) { + this.leftVariable = leftVariable; + this.rightVariable = rightVariable; + this.condition = condition; + this.leftSwizzling = leftSwizzling; + this.rightSwizzling = rightSwizzling; + } + + /** + * + * @return the left variable + */ + public ShaderNodeVariable getLeftVariable() { + return leftVariable; + } + + /** + * sets the left variable + * + * @param leftVariable the left variable + */ + public void setLeftVariable(ShaderNodeVariable leftVariable) { + this.leftVariable = leftVariable; + } + + /** + * + * @return the right variable + */ + public ShaderNodeVariable getRightVariable() { + return rightVariable; + } + + /** + * sets the right variable + * + * @param rightVariable the right variable + */ + public void setRightVariable(ShaderNodeVariable rightVariable) { + this.rightVariable = rightVariable; + } + + /** + * + * @return the condition + */ + public String getCondition() { + return condition; + } + + /** + * sets the condition + * + * @param condition the condition + */ + public void setCondition(String condition) { + this.condition = condition; + } + + /** + * + * @return the left swizzle + */ + public String getLeftSwizzling() { + return leftSwizzling; + } + + /** + * sets the left swizzle + * + * @param leftSwizzling the left swizzle + */ + public void setLeftSwizzling(String leftSwizzling) { + this.leftSwizzling = leftSwizzling; + } + + /** + * + * @return the right swizzle + */ + public String getRightSwizzling() { + return rightSwizzling; + } + + /** + * sets the right swizzle + * + * @param rightSwizzling the right swizzle + */ + public void setRightSwizzling(String rightSwizzling) { + this.rightSwizzling = rightSwizzling; + } + + /** + * jme serialization (not used) + * + * @param ex the exporter + * @throws IOException + */ + @Override + public void write(JmeExporter ex) throws IOException { + OutputCapsule oc = (OutputCapsule) ex.getCapsule(this); + oc.write(leftVariable, "leftVariable", null); + oc.write(rightVariable, "rightVariable", null); + oc.write(condition, "condition", ""); + oc.write(leftSwizzling, "leftSwizzling", ""); + oc.write(rightSwizzling, "rightSwizzling", ""); + } + + /** + * jme serialization (not used) + * + * @param im the importer + * @throws IOException + */ + @Override + public void read(JmeImporter im) throws IOException { + InputCapsule ic = (InputCapsule) im.getCapsule(this); + leftVariable = (ShaderNodeVariable) ic.readSavable("leftVariable", null); + rightVariable = (ShaderNodeVariable) ic.readSavable("rightVariable", null); + condition = ic.readString("condition", ""); + leftSwizzling = ic.readString("leftSwizzling", ""); + rightSwizzling = ic.readString("rightSwizzling", ""); + } + + @Override + public String toString() { + return leftVariable.toString() + (leftSwizzling.length() > 0 ? ("." + leftSwizzling) : "") + " = " + + rightVariable.getType() + " " + rightVariable.getNameSpace() + "." + rightVariable.getName() + + (rightSwizzling.length() > 0 ? ("." + rightSwizzling) : "") + " : " + condition; + } + + @Override + protected VariableMapping clone() throws CloneNotSupportedException { + VariableMapping clone = (VariableMapping) super.clone(); + + clone.leftVariable = leftVariable.clone(); + clone.rightVariable = rightVariable.clone(); + + return clone; + } +} From aa0b82dc7a18c3963397cf10b116c4eecb473239 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Sat, 9 Dec 2017 09:32:13 +0300 Subject: [PATCH 05/25] finished implementing value mapping. --- .../jme3/shader/Glsl100ShaderGenerator.java | 723 ++++++++++++++++++ .../jme3/shader/glsl/AstShaderGenerator.java | 17 + 2 files changed, 740 insertions(+) create mode 100644 src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java diff --git a/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java b/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java new file mode 100644 index 0000000..e0f8387 --- /dev/null +++ b/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java @@ -0,0 +1,723 @@ +/* + * Copyright (c) 2009-2012 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.shader; + +import com.jme3.asset.AssetManager; +import com.jme3.material.ShaderGenerationInfo; +import com.jme3.material.plugins.ConditionParser; +import com.jme3.shader.Shader.ShaderType; + +import java.util.ArrayList; +import java.util.List; + +/** + * This shader Generator can generate Vertex and Fragment shaders from + * shadernodes for GLSL 1.0 + * + * @author Nehon + */ +public class Glsl100ShaderGenerator extends ShaderGenerator { + + /** + * the indentation characters 1à tabulation characters + */ + private final static String INDENTCHAR = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; + protected ShaderNodeVariable inPosTmp; + + /** + * creates a Glsl100ShaderGenerator + * @param assetManager the assetManager + */ + public Glsl100ShaderGenerator(AssetManager assetManager) { + super(assetManager); + } + + @Override + protected void generateUniforms(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + generateUniforms(source, type == ShaderType.Vertex ? info.getVertexUniforms() : info.getFragmentUniforms()); + } + + /** + * declare a list of uniforms + * + * @param source the source to append to + * @param uniforms the list of uniforms + */ + protected void generateUniforms(StringBuilder source, List uniforms) { + source.append("\n"); + for (ShaderNodeVariable var : uniforms) { + declareVariable(source, var, false, "uniform"); + } + } + + /** + * {@inheritDoc} + * + * attributes are all declared, inPositon is declared even if it's not in + * the list and it's condition is nulled. + */ + @Override + protected void generateAttributes(StringBuilder source, ShaderGenerationInfo info) { + source.append("\n"); + boolean inPosition = false; + for (ShaderNodeVariable var : info.getAttributes()) { + if (var.getName().equals("inPosition")) { + inPosition = true; + var.setCondition(null); + fixInPositionType(var); + //keep track on the InPosition variable to avoid iterating through attributes again + inPosTmp = var; + } + declareAttribute(source, var); + + } + if (!inPosition) { + inPosTmp = new ShaderNodeVariable("vec3", "inPosition"); + declareAttribute(source, inPosTmp); + } + + } + + @Override + protected void generateVaryings(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + source.append("\n"); + for (ShaderNodeVariable var : info.getVaryings()) { + declareVarying(source, var, type != ShaderType.Vertex); + } + } + + /** + * {@inheritDoc} + * + * if the declaration contains no code nothing is done, else it's appended + */ + @Override + protected void generateDeclarativeSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info) { + if (nodeSource.replaceAll("\\n", "").trim().length() > 0) { + nodeSource = updateDefinesName(nodeSource, shaderNode); + source.append("\n"); + unIndent(); + startCondition(shaderNode.getCondition(), source); + source.append(nodeSource); + source.append("\n"); + endCondition(shaderNode.getCondition(), source); + indent(); + } + } + + /** + * {@inheritDoc} + * + * Shader outputs are declared and initialized inside the main section + */ + @Override + protected void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + source.append("\n"); + source.append("void main() {\n"); + indent(); + appendIndent(source); + if (type == ShaderType.Vertex) { + declareGlobalPosition(info, source); + } else if (type == ShaderType.Fragment) { + for (ShaderNodeVariable global : info.getFragmentGlobals()) { + declareVariable(source, global, "vec4(1.0)"); + } + } + source.append("\n"); + } + + /** + * {@inheritDoc} + * + * outputs are assigned to built in glsl output. then the main section is + * closed + * + * This code accounts for multi render target and correctly output to + * gl_FragData if several output are declared for the fragment shader + */ + @Override + protected void generateEndOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type) { + source.append("\n"); + if (type == ShaderType.Vertex) { + appendOutput(source, "gl_Position", info.getVertexGlobal()); + } else if (type == ShaderType.Fragment) { + List globals = info.getFragmentGlobals(); + if (globals.size() == 1) { + appendOutput(source, "gl_FragColor", globals.get(0)); + } else { + int i = 0; + //Multi Render Target + for (ShaderNodeVariable global : globals) { + appendOutput(source, "gl_FragData[" + i + "]", global); + i++; + } + } + } + unIndent(); + appendIndent(source); + source.append("}\n"); + } + + /** + * Appends an output assignment to a shader globalOutputName = + * nameSpace_varName; + * + * @param source the source StringBuilter to append the code. + * @param globalOutputName the name of the global output (can be gl_Position + * or gl_FragColor etc...). + * @param var the variable to assign to the output. + */ + protected void appendOutput(StringBuilder source, String globalOutputName, ShaderNodeVariable var) { + appendIndent(source); + source.append(globalOutputName); + source.append(" = "); + source.append(var.getNameSpace()); + source.append("_"); + source.append(var.getName()); + source.append(";\n"); + } + + /** + * {@inheritDoc} + * + * this methods does things in this order : + * + * 1. declaring and mapping input
+ * variables : variable replaced with MatParams or WorldParams that are Samplers are not + * declared and are replaced by the param actual name in the code. For others + * variables, the name space is appended with a "_" before the variable name + * in the code to avoid names collision between shaderNodes.
+ * + * 2. declaring output variables :
+ * variables are declared if they were not already + * declared as input (inputs can also be outputs) or if they are not + * declared as varyings. The variable name is also prefixed with the s=name + * space and "_" in the shaderNode code
+ * + * 3. append of the actual ShaderNode code
+ * + * 4. mapping outputs to global output if needed
+ * + *
+ * All of this is embed in a #if conditional statement if needed + */ + @Override + protected void generateNodeMainSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info) { + + nodeSource = updateDefinesName(nodeSource, shaderNode); + source.append("\n"); + comment(source, shaderNode, "Begin"); + startCondition(shaderNode.getCondition(), source); + + final List declaredInputs = new ArrayList<>(); + + for (VariableMapping mapping : shaderNode.getInputMapping()) { + + final ShaderNodeVariable rightVariable = mapping.getRightVariable(); + final ShaderNodeVariable leftVariable = mapping.getLeftVariable(); + + //Variables fed with a sampler matparam or world param are replaced by the matparam itself + //It avoids issue with samplers that have to be uniforms. + if (isWorldOrMaterialParam(rightVariable) && rightVariable.getType().startsWith("sampler")) { + nodeSource = replace(nodeSource, leftVariable, rightVariable.getPrefix() + rightVariable.getName()); + } else { + + if (leftVariable.getType().startsWith("sampler")) { + throw new IllegalArgumentException("a Sampler must be a uniform"); + } + + map(mapping, source); + } + + String newName = shaderNode.getName() + "_" + leftVariable.getName(); + if (!declaredInputs.contains(newName)) { + nodeSource = replace(nodeSource, leftVariable, newName); + declaredInputs.add(newName); + } + } + + final ShaderNodeDefinition definition = shaderNode.getDefinition(); + final List valueMapping = shaderNode.getValueMapping(); + + for (final ValueMapping mapping : valueMapping) { + + final ShaderNodeVariable variable = mapping.getVariable(); + + String newName = shaderNode.getName() + "_" + variable.getName(); + if (declaredInputs.contains(newName)) { + continue; + } + + map(mapping, source); + + nodeSource = replace(nodeSource, variable, newName); + declaredInputs.add(newName); + } + + for (final ShaderNodeVariable var : definition.getInputs()) { + + if (var.getDefaultValue() == null) { + continue; + } + + final String fullName = shaderNode.getName() + "_" + var.getName(); + + if (declaredInputs.contains(fullName)) { + continue; + } + + final ShaderNodeVariable variable = new ShaderNodeVariable(var.getType(), shaderNode.getName(), + var.getName(), var.getMultiplicity()); + + if (!isVarying(info, variable)) { + declareVariable(source, variable, var.getDefaultValue(), true, null); + } + + nodeSource = replaceVariableName(nodeSource, variable); + declaredInputs.add(fullName); + } + + for (ShaderNodeVariable var : definition.getOutputs()) { + ShaderNodeVariable v = new ShaderNodeVariable(var.getType(), shaderNode.getName(), var.getName(), var.getMultiplicity()); + if (!declaredInputs.contains(shaderNode.getName() + "_" + var.getName())) { + if (!isVarying(info, v)) { + declareVariable(source, v); + } + nodeSource = replaceVariableName(nodeSource, v); + } + } + + source.append(nodeSource); + + for (VariableMapping mapping : shaderNode.getOutputMapping()) { + map(mapping, source); + } + endCondition(shaderNode.getCondition(), source); + comment(source, shaderNode, "End"); + } + + /** + * declares a variable, embed in a conditional block if needed + * @param source the StringBuilder to use + * @param var the variable to declare + * @param appendNameSpace true to append the nameSpace + "_" + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace) { + declareVariable(source, var, appendNameSpace, null); + } + + /** + * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" + * @param source the StringBuilder to use + * @param var the variable to declare + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var) { + declareVariable(source, var, true, null); + } + + /** + * declares a variable, embed in a conditional block if needed. the namespace is appended with "_" + * @param source the StringBuilder to use + * @param var the variable to declare + * @param value the initialization value to assign the the variable + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var, String value) { + declareVariable(source, var, value, true, null); + } + + /** + * declares a variable, embed in a conditional block if needed. + * @param source the StringBuilder to use + * @param var the variable to declare + * @param appendNameSpace true to append the nameSpace + "_" + * @param modifier the modifier of the variable (attribute, varying, in , out,...) + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var, boolean appendNameSpace, String modifier) { + declareVariable(source, var, null, appendNameSpace, modifier); + } + + /** + * declares a variable, embed in a conditional block if needed. + * @param source the StringBuilder to use + * @param var the variable to declare + * @param value the initialization value to assign the the variable + * @param appendNameSpace true to append the nameSpace + "_" + * @param modifier the modifier of the variable (attribute, varying, in , out,...) + */ + protected void declareVariable(StringBuilder source, ShaderNodeVariable var, String value, boolean appendNameSpace, String modifier) { + startCondition(var.getCondition(), source); + appendIndent(source); + if (modifier != null) { + source.append(modifier); + source.append(" "); + } + + source.append(var.getType()); + source.append(" "); + if (appendNameSpace) { + source.append(var.getNameSpace()); + source.append("_"); + } + source.append(var.getPrefix()); + source.append(var.getName()); + if (var.getMultiplicity() != null) { + source.append("["); + source.append(var.getMultiplicity().toUpperCase()); + source.append("]"); + } + if (value != null) { + source.append(" = "); + source.append(value); + } + source.append(";\n"); + endCondition(var.getCondition(), source); + } + + /** + * Starts a conditional block + * @param condition the block condition + * @param source the StringBuilder to use + */ + protected void startCondition(String condition, StringBuilder source) { + if (condition != null) { + appendIndent(source); + source.append("#if "); + source.append(condition); + source.append("\n"); + indent(); + } + } + + /** + * Ends a conditional block + * @param condition the block condition + * @param source the StringBuilder to use + */ + protected void endCondition(String condition, StringBuilder source) { + if (condition != null) { + unIndent(); + appendIndent(source); + source.append("#endif\n"); + + } + } + + /** + * Appends a mapping to the source, embed in a conditional block if needed, + * with variables nameSpaces and swizzle. + * @param mapping the VariableMapping to append + * @param source the StringBuilder to use + */ + protected void map(VariableMapping mapping, StringBuilder source) { + + final ShaderNodeVariable leftVariable = mapping.getLeftVariable(); + final ShaderNodeVariable rightVariable = mapping.getRightVariable(); + + startCondition(mapping.getCondition(), source); + appendIndent(source); + if (!leftVariable.isShaderOutput()) { + source.append(leftVariable.getType()); + source.append(" "); + } + source.append(leftVariable.getNameSpace()); + source.append("_"); + source.append(leftVariable.getName()); + if (leftVariable.getMultiplicity() != null){ + source.append("["); + source.append(leftVariable.getMultiplicity()); + source.append("]"); + } + + //left swizzle, the variable can't be declared and assigned on the same line. + if (mapping.getLeftSwizzling().length() > 0) { + //initialize the declared variable to 0.0 + source.append(" = "); + source.append(leftVariable.getType()); + source.append("(0.0);\n"); + appendIndent(source); + //assign the value on a new line + source.append(leftVariable.getNameSpace()); + source.append("_"); + source.append(leftVariable.getName()); + source.append("."); + source.append(mapping.getLeftSwizzling()); + } + source.append(" = "); + String namePrefix = getAppendableNameSpace(rightVariable); + source.append(namePrefix); + source.append(rightVariable.getPrefix()); + source.append(rightVariable.getName()); + if (mapping.getRightSwizzling().length() > 0) { + source.append("."); + source.append(mapping.getRightSwizzling()); + } + source.append(";\n"); + endCondition(mapping.getCondition(), source); + } + + protected void map(final ValueMapping mapping, final StringBuilder source) { + + final ShaderNodeVariable variable = mapping.getVariable(); + final String type = variable.getType(); + final String value = mapping.getValue(); + + appendIndent(source); + + source.append(variable.getType()); + source.append(" "); + source.append(variable.getNameSpace()); + source.append("_"); + source.append(variable.getName()); + source.append(" = "); + + appendValue(type, value, source); + + source.append(";\n"); + } + + /** + * Append the value of the type to the source. + * + * @param type the value type. + * @param value the value. + * @param source the source. + */ + protected void appendValue(final String type, final String value, final StringBuilder source) { + switch (type) { + case "int": + case "bool": + case "unit": + case "double": + case "float": + source.append(value); + return; + } + + if (type.contains("vec")) { + source.append(type).append('(').append(value).append(')'); + return; + } + + throw new IllegalArgumentException("The value " + value + " with the type " + type + " doesn't support here."); + } + + /** + * replaces a variable name in a shaderNode source code by prefixing it + * with its nameSpace and "_" if needed. + * @param nodeSource the source to modify + * @param var the variable to replace + * @return the modified source + */ + protected String replaceVariableName(String nodeSource, ShaderNodeVariable var) { + String namePrefix = getAppendableNameSpace(var); + String newName = namePrefix + var.getName(); + nodeSource = replace(nodeSource, var, newName); + return nodeSource; + } + + /** + * Finds if a variable is a varying + * @param info the ShaderGenerationInfo + * @param v the variable + * @return true is the given variable is a varying + */ + protected boolean isVarying(ShaderGenerationInfo info, ShaderNodeVariable v) { + boolean isVarying = false; + for (ShaderNodeVariable shaderNodeVariable : info.getVaryings()) { + if (shaderNodeVariable.equals(v)) { + isVarying = true; + } + } + return isVarying; + } + + /** + * Appends a comment to the generated code + * @param source the StringBuilder to use + * @param shaderNode the shader node being processed (to append its name) + * @param comment the comment to append + */ + protected void comment(StringBuilder source, ShaderNode shaderNode, String comment) { + appendIndent(source); + source.append("//"); + source.append(shaderNode.getName()); + source.append(" : "); + source.append(comment); + source.append("\n"); + } + + /** + * returns the name space to append for a variable. + * Attributes, WorldParam and MatParam names space must not be appended + * @param var the variable + * @return the namespace to append for this variable + */ + protected String getAppendableNameSpace(ShaderNodeVariable var) { + String namePrefix = var.getNameSpace() + "_"; + if (namePrefix.equals("Attr_") || namePrefix.equals("WorldParam_") || namePrefix.equals("MatParam_")) { + namePrefix = ""; + } + return namePrefix; + } + + /** + * transforms defines name is the shader node code. + * One can use a #if defined(inputVariableName) in a shaderNode code. + * This method is responsible for changing the variable name with the + * appropriate defined based on the mapping condition of this variable. + * Complex condition syntax are handled. + * + * @param nodeSource the sahderNode source code + * @param shaderNode the ShaderNode being processed + * @return the modified shaderNode source. + */ + protected String updateDefinesName(String nodeSource, ShaderNode shaderNode) { + String[] lines = nodeSource.split("\\n"); + ConditionParser parser = new ConditionParser(); + for (String line : lines) { + + if (line.trim().startsWith("#if")) { + List params = parser.extractDefines(line.trim()); + String l = line.trim().replaceAll("defined", "").replaceAll("#if ", "").replaceAll("#ifdef", "");//parser.getFormattedExpression(); + boolean match = false; + for (String param : params) { + for (VariableMapping map : shaderNode.getInputMapping()) { + if ((map.getLeftVariable().getName()).equals(param)) { + if (map.getCondition() != null) { + l = l.replaceAll(param, map.getCondition()); + match = true; + } + } + } + } + if (match) { + nodeSource = nodeSource.replace(line.trim(), "#if " + l); + } + } + } + return nodeSource; + } + + /** + * replaced a variable name in a source code with the given name + * @param nodeSource the source to use + * @param var the variable + * @param newName the new name of the variable + * @return the modified source code + */ + protected String replace(String nodeSource, ShaderNodeVariable var, String newName) { + nodeSource = nodeSource.replaceAll("(?<=\\W)" + var.getName() + "(?=\\W)", newName); + return nodeSource; + } + + /** + * Finds if a variable is a world or a material parameter + * @param var the variable + * @return true if the variable is a Word or material parameter + */ + protected boolean isWorldOrMaterialParam(ShaderNodeVariable var) { + return var.getNameSpace().equals("MatParam") || var.getNameSpace().equals("WorldParam"); + } + + @Override + protected String getLanguageAndVersion(ShaderType type) { + return "GLSL100"; + } + + /** + * appends indentation. + * @param source + */ + protected void appendIndent(StringBuilder source) { + source.append(INDENTCHAR.substring(0, indent)); + } + + /** + * Declares an attribute + * @param source the StringBuilder to use + * @param var the variable to declare as an attribute + */ + protected void declareAttribute(StringBuilder source, ShaderNodeVariable var) { + declareVariable(source, var, false, "attribute"); + } + + /** + * Declares a varying + * @param source the StringBuilder to use + * @param var the variable to declare as an varying + * @param input a boolean set to true if the this varying is an input. + * this in not used in this implementation but can be used in overridings + * implementation + */ + protected void declareVarying(StringBuilder source, ShaderNodeVariable var, boolean input) { + declareVariable(source, var, true, "varying"); + } + + /** + * Decrease indentation with a check so the indent is never negative. + */ + protected void unIndent() { + indent--; + indent = Math.max(0, indent); + } + + /** + * increase indentation with a check so that indentation is never over 10 + */ + protected void indent() { + indent++; + indent = Math.min(10, indent); + } + + /** + * makes sure inPosition attribute is of type vec3 or vec4 + * @param var the inPosition attribute + */ + protected void fixInPositionType(ShaderNodeVariable var) { + if(!var.getType().equals("vec3") || !var.getType().equals("vec4")){ + var.setType("vec3"); + } + } + + /** + * declare and assign the global position in the vertex shader. + * @param info the shader generation info + * @param source the shader source being generated + */ + protected void declareGlobalPosition(ShaderGenerationInfo info, StringBuilder source) { + if(inPosTmp.getType().equals(info.getVertexGlobal().getType())){ + declareVariable(source, info.getVertexGlobal(), "inPosition"); + }else{ + declareVariable(source, info.getVertexGlobal(), "vec4(inPosition,1.0)"); + } + } +} diff --git a/src/main/java/com/jme3/shader/glsl/AstShaderGenerator.java b/src/main/java/com/jme3/shader/glsl/AstShaderGenerator.java index 1a57a69..e136ce4 100644 --- a/src/main/java/com/jme3/shader/glsl/AstShaderGenerator.java +++ b/src/main/java/com/jme3/shader/glsl/AstShaderGenerator.java @@ -542,6 +542,23 @@ protected void generateNodeMainSection(final StringBuilder source, final ShaderN } } + final List valueMapping = shaderNode.getValueMapping(); + + for (final ValueMapping mapping : valueMapping) { + + final ShaderNodeVariable variable = mapping.getVariable(); + + String newName = shaderNode.getName() + "_" + variable.getName(); + if (declaredVariables.contains(newName)) { + continue; + } + + map(mapping, source); + + nodeSource = replace(nodeSource, variable, newName); + declaredVariables.add(newName); + } + for (final ShaderNodeVariable var : definition.getInputs()) { if (var.getDefaultValue() == null) { From 18543fa96035db0ebc797f5368f61ce57c141df2 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Sun, 10 Dec 2017 13:54:41 +0300 Subject: [PATCH 06/25] reimplemented value mapping. --- .../materialdef/J3mdTechniqueDefWriter.java | 53 +-- .../plugins/ShaderNodeLoaderDelegate.java | 435 +++++++++--------- .../jme3/shader/Glsl100ShaderGenerator.java | 90 +--- .../java/com/jme3/shader/ShaderGenerator.java | 366 +++++++++++++++ src/main/java/com/jme3/shader/ShaderNode.java | 87 ++-- .../java/com/jme3/shader/ValueMapping.java | 97 ---- .../java/com/jme3/shader/VariableMapping.java | 123 +++-- .../jme3/shader/glsl/AstShaderGenerator.java | 21 +- .../shader/nodes/ShaderNodesContainer.java | 4 + 9 files changed, 756 insertions(+), 520 deletions(-) create mode 100644 src/main/java/com/jme3/shader/ShaderGenerator.java delete mode 100644 src/main/java/com/jme3/shader/ValueMapping.java diff --git a/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java b/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java index 41a637c..eabfda1 100644 --- a/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java +++ b/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java @@ -173,7 +173,6 @@ private void writeShaderNode( OutputStreamWriter out, ShaderNode shaderNode, Col final List inputMapping = shaderNode.getInputMapping(); final List outputMapping = shaderNode.getOutputMapping(); - final List valueMapping = shaderNode.getValueMapping(); if (!inputMapping.isEmpty()) { out.write(" InputMappings {\n"); @@ -191,14 +190,6 @@ private void writeShaderNode( OutputStreamWriter out, ShaderNode shaderNode, Col out.write(" }\n"); } - if (!valueMapping.isEmpty()) { - out.write(" ValueMappings {\n"); - for (ValueMapping mapping : valueMapping) { - writeValueMapping(out, mapping); - } - out.write(" }\n"); - } - out.write(" }\n"); } @@ -208,6 +199,7 @@ private void writeVariableMapping(final OutputStreamWriter out, final ShaderNode final ShaderNodeVariable leftVar = mapping.getLeftVariable(); final ShaderNodeVariable rightVar = mapping.getRightVariable(); + final String rightExpression = mapping.getRightExpression(); out.write(" "); @@ -225,21 +217,28 @@ private void writeVariableMapping(final OutputStreamWriter out, final ShaderNode out.write(" = "); - if (!rightVar.getNameSpace().equals(shaderNode.getName())) { - out.write(rightVar.getNameSpace()); - out.write("."); - } + if (rightVar != null) { - String rightVarName = rightVar.getName(); - if (rightVarName.startsWith("g_") || rightVarName.startsWith("m_")) { - rightVarName = rightVarName.substring(2, rightVarName.length()); - } + if (!rightVar.getNameSpace().equals(shaderNode.getName())) { + out.write(rightVar.getNameSpace()); + out.write("."); + } - out.write(rightVarName); + String rightVarName = rightVar.getName(); + if (rightVarName.startsWith("g_") || rightVarName.startsWith("m_")) { + rightVarName = rightVarName.substring(2, rightVarName.length()); + } - if (!mapping.getRightSwizzling().equals("")) { - out.write("."); - out.write(mapping.getRightSwizzling()); + out.write(rightVarName); + + if (!mapping.getRightSwizzling().equals("")) { + out.write("."); + out.write(mapping.getRightSwizzling()); + } + } else { + out.write("%%"); + out.write(rightExpression); + out.write("%%"); } if (mapping.getCondition() != null) { @@ -250,18 +249,6 @@ private void writeVariableMapping(final OutputStreamWriter out, final ShaderNode out.write("\n"); } - private void writeValueMapping(final OutputStreamWriter out, final ValueMapping mapping) throws IOException { - - final ShaderNodeVariable variable = mapping.getVariable(); - final String value = mapping.getValue(); - - out.write(" "); - out.write(variable.getName()); - out.write(" = "); - out.write(value); - out.write("\n"); - } - private String formatCondition(String condition, Collection matParams){ //condition = condition.replaceAll("defined\\(",""); diff --git a/src/main/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java b/src/main/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java index bc40565..0a345b1 100644 --- a/src/main/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java +++ b/src/main/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java @@ -38,6 +38,7 @@ import com.jme3.material.MaterialDef; import com.jme3.material.ShaderGenerationInfo; import com.jme3.material.TechniqueDef; +import com.jme3.shader.Shader.ShaderType; import com.jme3.shader.*; import com.jme3.util.blockparser.Statement; @@ -59,6 +60,9 @@ */ public class ShaderNodeLoaderDelegate { + private static final boolean[] IM_HAS_NAME_SPACE = {false, true}; + private static final boolean[] OM_HAS_NAME_SPACE = {true, false}; + protected Map nodeDefinitions; protected Map nodes; protected ShaderNodeDefinition shaderNodeDefinition; @@ -159,7 +163,7 @@ protected void readShaderNodeDefinition(List statements, ShaderNodeDe if (line.startsWith("Type")) { String type = line.substring(line.lastIndexOf(':') + 1).trim(); - shaderNodeDefinition.setType(Shader.ShaderType.valueOf(type)); + shaderNodeDefinition.setType(ShaderType.valueOf(type)); } else if (line.startsWith("Shader ")) { readShaderStatement(statement); shaderNodeDefinition.getShadersLanguage().add(shaderLanguage); @@ -261,66 +265,86 @@ public void readVertexShaderNodes(List statements) throws IOException * @throws IOException */ protected void readShaderNode(List statements) throws IOException { + + final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); + final List unusedNodes = generationInfo.getUnusedNodes(); + for (Statement statement : statements) { + String line = statement.getLine(); String[] split = statement.getLine().split("[ \\{]"); + if (line.startsWith("Definition")) { ShaderNodeDefinition def = findDefinition(statement); shaderNode.setDefinition(def); if(def.isNoOutput()){ - techniqueDef.getShaderGenerationInfo().getUnusedNodes().remove(shaderNode.getName()); + unusedNodes.remove(shaderNode.getName()); } } else if (line.startsWith("Condition")) { String condition = line.substring(line.lastIndexOf(":") + 1).trim(); extractCondition(condition, statement); shaderNode.setCondition(conditionParser.getFormattedExpression()); } else if (line.startsWith("InputMappings")) { - for (Statement statement1 : statement.getContents()) { - VariableMapping mapping = readInputMapping(statement1); - techniqueDef.getShaderGenerationInfo().getUnusedNodes().remove(mapping.getRightVariable().getNameSpace()); + for (final Statement subStatement : statement.getContents()) { + + VariableMapping mapping = readInputMapping(subStatement); + + final ShaderNodeVariable rightVariable = mapping.getRightVariable(); + if (rightVariable != null) { + unusedNodes.remove(rightVariable.getNameSpace()); + } + shaderNode.getInputMapping().add(mapping); } } else if (line.startsWith("OutputMappings")) { for (Statement statement1 : statement.getContents()) { VariableMapping mapping = readOutputMapping(statement1); - techniqueDef.getShaderGenerationInfo().getUnusedNodes().remove(shaderNode.getName()); + unusedNodes.remove(shaderNode.getName()); shaderNode.getOutputMapping().add(mapping); } - } else if (line.startsWith("ValueMappings")) { - for (final Statement mappingStatement : statement.getContents()) { - final ValueMapping mapping = readValueMapping(mappingStatement); - shaderNode.getValueMapping().add(mapping); - } } else { throw new MatParseException("ShaderNodeDefinition", split[0], statement); } } - } /** - * reads a mapping statement. Sets the nameSpace, name and swizzling of the + * Reads a mapping statement. Sets the nameSpace, name and swizzling of the * left variable. Sets the name, nameSpace and swizzling of the right - * variable types will be determined later. - * - * - * Format : .[.] = - * .[.][:Condition] - * + * variable types will be determined later. Also, we can have the right part as expression. + *
+     * Format variable to variable: <nameSpace>.<varName>[.<swizzling>] = <nameSpace>.<varName>[.<swizzling>][:Condition]
+     * Format expression to variable: <nameSpace>.<varName>[.<swizzling>] = %% expression %% [:Condition]
+     * 
* - * @param statement the statement to read - * @return the read mapping + * @param statement the statement to read. + * @return the read mapping. + * @throws MatParseException if the statement isn't valid. */ - protected VariableMapping parseMapping(Statement statement, boolean[] hasNameSpace) throws IOException { + protected VariableMapping parseMapping(Statement statement, boolean[] hasNameSpace) throws MatParseException { + VariableMapping mapping = new VariableMapping(); String[] cond = statement.getLine().split(":"); - String[] vars = cond[0].split("="); + checkMappingFormat(vars, statement); + ShaderNodeVariable[] variables = new ShaderNodeVariable[2]; String[] swizzle = new String[2]; + String rightExpression = null; + for (int i = 0; i < vars.length; i++) { - String[] expression = vars[i].trim().split("\\."); + + final String var = vars[i].trim(); + + // it seems that is expression, not variable + if (var.contains("%%")) { + rightExpression = var.substring(2, var.length() - 2); + continue; + } + + String[] expression = var.split("\\."); + if (hasNameSpace[i]) { if (expression.length <= 3) { variables[i] = new ShaderNodeVariable("", expression[0].trim(), expression[1].trim()); @@ -336,13 +360,17 @@ protected VariableMapping parseMapping(Statement statement, boolean[] hasNameSpa swizzle[i] = expression[1].trim(); } } - } mapping.setLeftVariable(variables[0]); mapping.setLeftSwizzling(swizzle[0] != null ? swizzle[0] : ""); - mapping.setRightVariable(variables[1]); - mapping.setRightSwizzling(swizzle[1] != null ? swizzle[1] : ""); + + if (rightExpression != null) { + mapping.setRightExpression(rightExpression); + } else { + mapping.setRightVariable(variables[1]); + mapping.setRightSwizzling(swizzle[1] != null ? swizzle[1] : ""); + } if (cond.length > 1) { extractCondition(cond[1], statement); @@ -352,32 +380,6 @@ protected VariableMapping parseMapping(Statement statement, boolean[] hasNameSpa return mapping; } - /** - * Reads a value mapping. - *
-     *  Format : <varName> = <value>
-     * 
- * - * @param statement the statement to read. - * @return the read mapping - */ - protected ValueMapping parseValueMapping(final Statement statement) throws IOException { - - final String[] vars = statement.getLine().split("="); - - checkMappingFormat(vars, statement); - - final String[] expression = vars[0].trim().split("\\."); - final ShaderNodeVariable variable = new ShaderNodeVariable("", expression[0].trim()); - final String value = vars[1].trim(); - - final ValueMapping mapping = new ValueMapping(); - mapping.setVariable(variable); - mapping.setValue(value); - - return mapping; - } - /** * reads the FragmentShaderNodes{} block * @@ -426,11 +428,11 @@ public void setMaterialDef(MaterialDef materialDef) { } /** - * search a variable in the given list and updates its type and namespace + * Searches a variable in the given list and updates its type and namespace. * - * @param var the variable to update - * @param list the variables list - * @return true if the variable has been found and updated + * @param var the variable to update. + * @param list the variables list. + * @return true if the variable has been found and updated. */ protected boolean updateVariableFromList(ShaderNodeVariable var, List list) { for (ShaderNodeVariable shaderNodeVariable : list) { @@ -445,10 +447,10 @@ protected boolean updateVariableFromList(ShaderNodeVariable var, List[.] = .[.][:Condition]'", statement); + throw new MatParseException("Not a valid expression should be '[.] = " + + ".[.][:Condition]'", statement); } } /** - * finds a MatParam in the materialDef from the given name + * Finds a {@link MatParam} in the {@link MaterialDef} from the given name. * - * @param varName the matparam name - * @return the MatParam + * @param varName the material param name. + * @return the found {@link MatParam} or null. */ protected MatParam findMatParam(String varName) { for (MatParam matParam : materialDef.getMaterialParams()) { @@ -518,6 +521,7 @@ protected UniformBinding findWorldParam(String varName) { * @return true if the param was added to the map */ protected boolean updateRightFromUniforms(UniformBinding param, VariableMapping mapping, Map map) { + ShaderNodeVariable right = mapping.getRightVariable(); String name = param.toString(); @@ -538,60 +542,74 @@ protected boolean updateRightFromUniforms(UniformBinding param, VariableMapping } /** - * updates the right variable of the given mapping from a MatParam (a + * Updates the right variable of the given mapping from a {@link MatParam} (a * WorldParam) it checks if the uniform hasn't already been loaded, add it * to the maps if not. * - * @param param the MatParam - * @param mapping the mapping - * @param map the map of uniforms to search into - * @return true if the param was added to the map + * @param param the mat param. + * @param mapping the mapping. + * @param map the map of uniforms to search into. + * @return true if the param was added to the map. */ - public boolean updateRightFromUniforms(MatParam param, VariableMapping mapping, Map map, Statement statement) throws MatParseException { - ShaderNodeVariable right = mapping.getRightVariable(); + public boolean updateRightFromUniforms(MatParam param, VariableMapping mapping, Map map, + Statement statement) throws MatParseException { + + final ShaderNodeVariable left = mapping.getLeftVariable(); + final ShaderNodeVariable right = mapping.getRightVariable(); + DeclaredVariable dv = map.get(param.getName()); + if (dv == null) { + right.setType(param.getVarType().getGlslType()); right.setName(param.getName()); right.setPrefix("m_"); - if(mapping.getLeftVariable().getMultiplicity() != null){ - if(!param.getVarType().name().endsWith("Array")){ + + if (left.getMultiplicity() != null) { + + if (!param.getVarType().name().endsWith("Array")) { throw new MatParseException(param.getName() + " is not of Array type", statement); } - String multiplicity = mapping.getLeftVariable().getMultiplicity(); + + String multiplicity = left.getMultiplicity(); try { Integer.parseInt(multiplicity); - } catch (NumberFormatException nfe) { - //multiplicity is not an int attempting to find for a material parameter. + } catch (final NumberFormatException nfe) { + // multiplicity is not an int attempting to find for a material parameter. MatParam mp = findMatParam(multiplicity); if (mp != null) { - //It's tied to a material param, let's create a define and use this as the multiplicity + // It's tied to a material param, let's create a define and use this as the multiplicity addDefine(multiplicity, VarType.Int); multiplicity = multiplicity.toUpperCase(); - mapping.getLeftVariable().setMultiplicity(multiplicity); - //only declare the variable if the define is defined. - mapping.getLeftVariable().setCondition(mergeConditions(mapping.getLeftVariable().getCondition(), "defined(" + multiplicity + ")", "||")); + left.setMultiplicity(multiplicity); + // only declare the variable if the define is defined. + left.setCondition(mergeConditions(left.getCondition(), "defined(" + multiplicity + ")", "||")); } else { - throw new MatParseException("Wrong multiplicity for variable" + mapping.getLeftVariable().getName() + ". " + multiplicity + " should be an int or a declared material parameter.", statement); + throw new MatParseException("Wrong multiplicity for variable" + left.getName() + ". " + + multiplicity + " should be an int or a declared material parameter.", statement); } } - //the right variable must have the same multiplicity and the same condition. + + // the right variable must have the same multiplicity and the same condition. right.setMultiplicity(multiplicity); - right.setCondition(mapping.getLeftVariable().getCondition()); + right.setCondition(left.getCondition()); } + dv = new DeclaredVariable(right); map.put(right.getName(), dv); dv.addNode(shaderNode); mapping.setRightVariable(right); return true; } + dv.addNode(shaderNode); mapping.setRightVariable(dv.var); + return false; } /** - * updates a variable from the Attribute list + * Updates a variable from the attribute list. * * @param right the variable * @param mapping the mapping @@ -620,11 +638,11 @@ public void addDefine(String paramName, VarType paramType) { } /** - * find a variable with the given name from the list of variable + * Finds a variable with the given name from the list of variable. * - * @param vars a list of shaderNodeVariables - * @param rightVarName the variable name to search for - * @return the found variable or null is not found + * @param vars the list of shader node variables. + * @param rightVarName the variable name to search for. + * @return the found variable or null is not found. */ public ShaderNodeVariable findNodeOutput(List vars, String rightVarName) { ShaderNodeVariable var = null; @@ -637,81 +655,95 @@ public ShaderNodeVariable findNodeOutput(List vars, String r } /** - * extract and check a condition expression + * Extracts and checks a condition expression. * - * @param cond the condition expression - * @param statement the statement being read - * @throws IOException + * @param condition the condition expression. + * @param statement the statement being read. + * @throws MatParseException if the condition isn't valid. */ - public void extractCondition(String cond, Statement statement) throws IOException { - List defines = conditionParser.extractDefines(cond); + public void extractCondition(String condition, Statement statement) throws MatParseException { + List defines = conditionParser.extractDefines(condition); for (String string : defines) { MatParam param = findMatParam(string); if (param != null) { addDefine(param.getName(), param.getVarType()); } else { - throw new MatParseException("Invalid condition, condition must match a Material Parameter named " + cond, statement); + throw new MatParseException("Invalid condition, condition must match a Material Parameter named " + condition, statement); } } } /** - * reads an input mapping + * Reads an input mapping. * - * @param statement1 the statement being read - * @return the mapping - * @throws IOException + * @param statement the statement being read. + * @return the variable mapping. + * @throws MatParseException if we have a problem with parsing input mapping statement. */ - public VariableMapping readInputMapping(Statement statement1) throws IOException { - VariableMapping mapping = null; + public VariableMapping readInputMapping(Statement statement) throws MatParseException { + + VariableMapping mapping; try { - mapping = parseMapping(statement1, new boolean[]{false, true}); - } catch (Exception e) { - throw new MatParseException("Unexpected mapping format", statement1, e); + mapping = parseMapping(statement, IM_HAS_NAME_SPACE); + } catch (final Exception e) { + throw new MatParseException("Unexpected mapping format", statement, e); } - ShaderNodeVariable left = mapping.getLeftVariable(); - ShaderNodeVariable right = mapping.getRightVariable(); - if (!updateVariableFromList(left, shaderNode.getDefinition().getInputs())) { - throw new MatParseException(left.getName() + " is not an input variable of " + shaderNode.getDefinition().getName(), statement1); + + final ShaderNodeDefinition definition = shaderNode.getDefinition(); + final ShaderNodeVariable left = mapping.getLeftVariable(); + final ShaderNodeVariable right = mapping.getRightVariable(); + final String expression = mapping.getRightExpression(); + + if (!updateVariableFromList(left, definition.getInputs())) { + throw new MatParseException(left.getName() + " is not an input variable of " + definition.getName(), statement); + } else if (left.getType().startsWith("sampler") && (right == null || !right.getNameSpace().equals(ShaderGenerator.NAME_SPACE_MAT_PARAM))) { + throw new MatParseException("Samplers can only be assigned to MatParams", statement); } - if (left.getType().startsWith("sampler") && !right.getNameSpace().equals("MatParam")) { - throw new MatParseException("Samplers can only be assigned to MatParams", statement1); + if (right == null && expression == null) { + throw new MatParseException("The mapping doesn't have a right variable or a right expression.", statement); } - if (right.getNameSpace().equals("Global")) { - right.setType("vec4");//Globals are all vec4 for now (maybe forever...) - storeGlobal(right, statement1); + if (right == null) { + return mapping; + } - } else if (right.getNameSpace().equals("Attr")) { - if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) { - throw new MatParseException("Cannot have an attribute as input in a fragment shader" + right.getName(), statement1); + if (right.getNameSpace().equals(ShaderGenerator.NAME_SPACE_GLOBAL)) { + right.setType("vec4"); // Globals are all vec4 for now (maybe forever...) + storeGlobal(right, statement); + } else if (right.getNameSpace().equals(ShaderGenerator.NAME_SPACE_VERTEX_ATTRIBUTE)) { + if (definition.getType() == ShaderType.Fragment) { + throw new MatParseException("Cannot have an attribute as input in a fragment shader" + right.getName(), statement); } updateVarFromAttributes(mapping.getRightVariable(), mapping); storeAttribute(mapping.getRightVariable()); - } else if (right.getNameSpace().equals("MatParam")) { + } else if (right.getNameSpace().equals(ShaderGenerator.NAME_SPACE_MAT_PARAM)) { + MatParam param = findMatParam(right.getName()); if (param == null) { - throw new MatParseException("Could not find a Material Parameter named " + right.getName(), statement1); + throw new MatParseException("Could not find a Material Parameter named " + right.getName(), statement); } - if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { - if (updateRightFromUniforms(param, mapping, vertexDeclaredUniforms, statement1)) { - updateMaterialTextureType(statement1, mapping, left, param); + + if (definition.getType() == ShaderType.Vertex) { + if (updateRightFromUniforms(param, mapping, vertexDeclaredUniforms, statement)) { + updateMaterialTextureType(statement, mapping, left, param); storeVertexUniform(mapping.getRightVariable()); } } else { - if (updateRightFromUniforms(param, mapping, fragmentDeclaredUniforms, statement1)) { - updateMaterialTextureType(statement1, mapping, left, param); + if (updateRightFromUniforms(param, mapping, fragmentDeclaredUniforms, statement)) { + updateMaterialTextureType(statement, mapping, left, param); storeFragmentUniform(mapping.getRightVariable()); } } - } else if (right.getNameSpace().equals("WorldParam")) { + } else if (right.getNameSpace().equals(ShaderGenerator.NAME_SPACE_WORLD_PARAM)) { + UniformBinding worldParam = findWorldParam(right.getName()); if (worldParam == null) { - throw new MatParseException("Could not find a World Parameter named " + right.getName(), statement1); + throw new MatParseException("Could not find a World Parameter named " + right.getName(), statement); } - if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { + + if (definition.getType() == ShaderType.Vertex) { if (updateRightFromUniforms(worldParam, mapping, vertexDeclaredUniforms)) { storeVertexUniform(mapping.getRightVariable()); } @@ -722,35 +754,43 @@ public VariableMapping readInputMapping(Statement statement1) throws IOException } } else { + ShaderNode node = nodes.get(right.getNameSpace()); + if (node == null) { - throw new MatParseException("Undeclared node" + right.getNameSpace() + ". Make sure this node is declared before the current node", statement1); + throw new MatParseException("Undeclared node" + right.getNameSpace() + + ". Make sure this node is declared before the current node", statement); } + ShaderNodeVariable var = findNodeOutput(node.getDefinition().getOutputs(), right.getName()); + if (var == null) { - throw new MatParseException("Cannot find output variable" + right.getName() + " form ShaderNode " + node.getName(), statement1); + throw new MatParseException("Cannot find output variable" + right.getName() + + " form ShaderNode " + node.getName(), statement); } + right.setNameSpace(node.getName()); right.setType(var.getType()); right.setMultiplicity(var.getMultiplicity()); + mapping.setRightVariable(right); - storeVaryings(node, mapping.getRightVariable()); + storeVaryings(node, mapping.getRightVariable()); } - checkTypes(mapping, statement1); + checkTypes(mapping, statement); return mapping; } /** - * Updated the material texture type of the variable mapping. + * Updates the material texture type of the variable mapping. * * @param statement the statement. * @param mapping the variable mapping. * @param left the left variable. * @param param the material parameter. - * @throws MatParseException + * @throws MatParseException if the texture type isn't valid. */ private void updateMaterialTextureType(final Statement statement, final VariableMapping mapping, final ShaderNodeVariable left, final MatParam param) throws MatParseException { @@ -770,66 +810,41 @@ private void updateMaterialTextureType(final Statement statement, final Variable } /** - * reads an output mapping + * Reads an output mapping. * - * @param statement1 the statement being read + * @param statement the statement being read. * @return the mapping - * @throws IOException + * @throws MatParseException if we have a problem with parsing the statement. */ - public VariableMapping readOutputMapping(Statement statement1) throws IOException { - VariableMapping mapping = null; + public VariableMapping readOutputMapping(Statement statement) throws MatParseException { + + VariableMapping mapping; try { - mapping = parseMapping(statement1, new boolean[]{true, false}); - } catch (Exception e) { - throw new MatParseException("Unexpected mapping format", statement1, e); + mapping = parseMapping(statement, OM_HAS_NAME_SPACE); + } catch (final Exception e) { + throw new MatParseException("Unexpected mapping format", statement, e); } - ShaderNodeVariable left = mapping.getLeftVariable(); - ShaderNodeVariable right = mapping.getRightVariable(); + final ShaderNodeDefinition definition = shaderNode.getDefinition(); + final ShaderNodeVariable left = mapping.getLeftVariable(); + final ShaderNodeVariable right = mapping.getRightVariable(); if (left.getType().startsWith("sampler") || right.getType().startsWith("sampler")) { - throw new MatParseException("Samplers can only be inputs", statement1); + throw new MatParseException("Samplers can only be inputs", statement); } - if (left.getNameSpace().equals("Global")) { - left.setType("vec4");//Globals are all vec4 for now (maybe forever...) - storeGlobal(left, statement1); + if (left.getNameSpace().equals(ShaderGenerator.NAME_SPACE_GLOBAL)) { + left.setType("vec4"); // Globals are all vec4 for now (maybe forever...) + storeGlobal(left, statement); } else { - throw new MatParseException("Only Global nameSpace is allowed for outputMapping, got" + left.getNameSpace(), statement1); - } - - if (!updateVariableFromList(right, shaderNode.getDefinition().getOutputs())) { - throw new MatParseException(right.getName() + " is not an output variable of " + shaderNode.getDefinition().getName(), statement1); + throw new MatParseException("Only Global nameSpace is allowed for outputMapping, got" + left.getNameSpace(), statement); } - checkTypes(mapping, statement1); - - return mapping; - } - - /** - * Reads a value mapping. - * - * @param statement the statement to read. - * @return the value mapping. - * @throws IOException - */ - public ValueMapping readValueMapping(final Statement statement) throws IOException { - - ValueMapping mapping; - try { - mapping = parseValueMapping(statement); - } catch (final Exception e) { - throw new MatParseException("Unexpected mapping format", statement, e); + if (!updateVariableFromList(right, definition.getOutputs())) { + throw new MatParseException(right.getName() + " is not an output variable of " + definition.getName(), statement); } - final ShaderNodeVariable variable = mapping.getVariable(); - final ShaderNodeDefinition definition = shaderNode.getDefinition(); - - if (!updateVariableFromList(variable, definition.getInputs())) { - throw new MatParseException(variable.getName() + " is not an input variable of " + - definition.getName(), statement); - } + checkTypes(mapping, statement); return mapping; } @@ -889,45 +904,54 @@ public String fixSamplerType(String leftType, String rightType) { } /** - * stores a global output + * Stores a global output. * - * @param var the variable to store - * @param statement1 the statement being read - * @throws IOException + * @param var the variable to store. + * @param varStatement the statement being read. + * @throws MatParseException if we have duplicates of a global vertex output variable. */ - public void storeGlobal(ShaderNodeVariable var, Statement statement1) throws IOException { + public void storeGlobal(ShaderNodeVariable var, Statement varStatement) throws MatParseException { var.setShaderOutput(true); - if (shaderNode.getDefinition().getType() == Shader.ShaderType.Vertex) { - ShaderNodeVariable global = techniqueDef.getShaderGenerationInfo().getVertexGlobal(); + + final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); + final ShaderNodeDefinition definition = shaderNode.getDefinition(); + + if (definition.getType() == ShaderType.Vertex) { + + ShaderNodeVariable global = generationInfo.getVertexGlobal(); + if (global != null) { + if (!global.getName().equals(var.getName())) { - throw new MatParseException("A global output is already defined for the vertex shader: " + global.getName() + ". vertex shader can only have one global output", statement1); + throw new MatParseException("A global output is already defined for the vertex shader: " + + global.getName() + ". vertex shader can only have one global output", varStatement); } + } else { - techniqueDef.getShaderGenerationInfo().setVertexGlobal(var); + generationInfo.setVertexGlobal(var); } - } else if (shaderNode.getDefinition().getType() == Shader.ShaderType.Fragment) { - storeVariable(var, techniqueDef.getShaderGenerationInfo().getFragmentGlobals()); + + } else if (definition.getType() == ShaderType.Fragment) { + storeVariable(var, generationInfo.getFragmentGlobals()); } } /** - * store an attribute + * Stores an attribute. * - * @param var the variable to store + * @param var the variable to store. */ public void storeAttribute(ShaderNodeVariable var) { storeVariable(var, techniqueDef.getShaderGenerationInfo().getAttributes()); } /** - * store a vertex uniform + * Stores a vertex uniform. * - * @param var the variable to store + * @param var the variable to store. */ public void storeVertexUniform(ShaderNodeVariable var) { storeVariable(var, techniqueDef.getShaderGenerationInfo().getVertexUniforms()); - } /** @@ -937,7 +961,6 @@ public void storeVertexUniform(ShaderNodeVariable var) { */ public void storeFragmentUniform(ShaderNodeVariable var) { storeVariable(var, techniqueDef.getShaderGenerationInfo().getFragmentUniforms()); - } /** @@ -1010,8 +1033,8 @@ public void storeVaryings(ShaderNode node, ShaderNodeVariable variable) { final ShaderNodeDefinition nodeDefinition = node.getDefinition(); final ShaderNodeDefinition currentDefinition = shaderNode.getDefinition(); - if (nodeDefinition.getType() != Shader.ShaderType.Vertex || - currentDefinition.getType() != Shader.ShaderType.Fragment) { + if (nodeDefinition.getType() != ShaderType.Vertex || + currentDefinition.getType() != ShaderType.Fragment) { return; } @@ -1059,11 +1082,11 @@ public String mergeConditions(String condition1, String condition2, String opera } /** - * search a variable in a list from its name and merge the conditions of the - * variables + * Searches a variable in a list from its name and merges the conditions of the + * variables. * - * @param variable the variable - * @param varList the variable list + * @param variable the variable. + * @param varList the variable list. */ public void storeVariable(ShaderNodeVariable variable, List varList) { for (ShaderNodeVariable var : varList) { diff --git a/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java b/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java index e0f8387..601bcbe 100644 --- a/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java +++ b/src/main/java/com/jme3/shader/Glsl100ShaderGenerator.java @@ -51,6 +51,7 @@ public class Glsl100ShaderGenerator extends ShaderGenerator { * the indentation characters 1à tabulation characters */ private final static String INDENTCHAR = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; + protected ShaderNodeVariable inPosTmp; /** @@ -247,7 +248,7 @@ protected void generateNodeMainSection(StringBuilder source, ShaderNode shaderNo //Variables fed with a sampler matparam or world param are replaced by the matparam itself //It avoids issue with samplers that have to be uniforms. - if (isWorldOrMaterialParam(rightVariable) && rightVariable.getType().startsWith("sampler")) { + if (rightVariable != null && isWorldOrMaterialParam(rightVariable) && rightVariable.getType().startsWith("sampler")) { nodeSource = replace(nodeSource, leftVariable, rightVariable.getPrefix() + rightVariable.getName()); } else { @@ -266,22 +267,6 @@ protected void generateNodeMainSection(StringBuilder source, ShaderNode shaderNo } final ShaderNodeDefinition definition = shaderNode.getDefinition(); - final List valueMapping = shaderNode.getValueMapping(); - - for (final ValueMapping mapping : valueMapping) { - - final ShaderNodeVariable variable = mapping.getVariable(); - - String newName = shaderNode.getName() + "_" + variable.getName(); - if (declaredInputs.contains(newName)) { - continue; - } - - map(mapping, source); - - nodeSource = replace(nodeSource, variable, newName); - declaredInputs.add(newName); - } for (final ShaderNodeVariable var : definition.getInputs()) { @@ -434,13 +419,15 @@ protected void endCondition(String condition, StringBuilder source) { /** * Appends a mapping to the source, embed in a conditional block if needed, * with variables nameSpaces and swizzle. + * * @param mapping the VariableMapping to append - * @param source the StringBuilder to use + * @param source the StringBuilder to use */ protected void map(VariableMapping mapping, StringBuilder source) { final ShaderNodeVariable leftVariable = mapping.getLeftVariable(); final ShaderNodeVariable rightVariable = mapping.getRightVariable(); + final String rightExpression = mapping.getRightExpression(); startCondition(mapping.getCondition(), source); appendIndent(source); @@ -457,14 +444,14 @@ protected void map(VariableMapping mapping, StringBuilder source) { source.append("]"); } - //left swizzle, the variable can't be declared and assigned on the same line. + // left swizzle, the variable can't be declared and assigned on the same line. if (mapping.getLeftSwizzling().length() > 0) { //initialize the declared variable to 0.0 source.append(" = "); source.append(leftVariable.getType()); source.append("(0.0);\n"); appendIndent(source); - //assign the value on a new line + // assign the value on a new line source.append(leftVariable.getNameSpace()); source.append("_"); source.append(leftVariable.getName()); @@ -472,62 +459,25 @@ protected void map(VariableMapping mapping, StringBuilder source) { source.append(mapping.getLeftSwizzling()); } source.append(" = "); - String namePrefix = getAppendableNameSpace(rightVariable); - source.append(namePrefix); - source.append(rightVariable.getPrefix()); - source.append(rightVariable.getName()); - if (mapping.getRightSwizzling().length() > 0) { - source.append("."); - source.append(mapping.getRightSwizzling()); - } - source.append(";\n"); - endCondition(mapping.getCondition(), source); - } - - protected void map(final ValueMapping mapping, final StringBuilder source) { - - final ShaderNodeVariable variable = mapping.getVariable(); - final String type = variable.getType(); - final String value = mapping.getValue(); - - appendIndent(source); - - source.append(variable.getType()); - source.append(" "); - source.append(variable.getNameSpace()); - source.append("_"); - source.append(variable.getName()); - source.append(" = "); - appendValue(type, value, source); + if (rightVariable != null) { - source.append(";\n"); - } + String namePrefix = getAppendableNameSpace(rightVariable); + source.append(namePrefix); + source.append(rightVariable.getPrefix()); + source.append(rightVariable.getName()); - /** - * Append the value of the type to the source. - * - * @param type the value type. - * @param value the value. - * @param source the source. - */ - protected void appendValue(final String type, final String value, final StringBuilder source) { - switch (type) { - case "int": - case "bool": - case "unit": - case "double": - case "float": - source.append(value); - return; - } + if (mapping.getRightSwizzling().length() > 0) { + source.append("."); + source.append(mapping.getRightSwizzling()); + } - if (type.contains("vec")) { - source.append(type).append('(').append(value).append(')'); - return; + } else { + source.append(rightExpression); } - throw new IllegalArgumentException("The value " + value + " with the type " + type + " doesn't support here."); + source.append(";\n"); + endCondition(mapping.getCondition(), source); } /** diff --git a/src/main/java/com/jme3/shader/ShaderGenerator.java b/src/main/java/com/jme3/shader/ShaderGenerator.java new file mode 100644 index 0000000..4086036 --- /dev/null +++ b/src/main/java/com/jme3/shader/ShaderGenerator.java @@ -0,0 +1,366 @@ +/* + * Copyright (c) 2009-2012 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.shader; + +import com.jme3.asset.AssetManager; +import com.jme3.material.ShaderGenerationInfo; +import com.jme3.material.TechniqueDef; +import com.jme3.shader.Shader.ShaderType; +import com.jme3.shader.plugins.ShaderAssetKey; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * This class is the base for a shader generator using the ShaderNodes system, + * it contains basis mechanism of generation, but no actual generation code. + * This class is abstract, any Shader generator must extend it. + * + * @author Nehon + */ +public abstract class ShaderGenerator { + + public static final String NAME_SPACE_GLOBAL = "Global"; + public static final String NAME_SPACE_VERTEX_ATTRIBUTE = "Attr"; + public static final String NAME_SPACE_MAT_PARAM = "MatParam"; + public static final String NAME_SPACE_WORLD_PARAM = "WorldParam"; + + /** + * the asset manager + */ + protected AssetManager assetManager; + /** + * indentation value for generation + */ + protected int indent; + /** + * the technique def to use for the shader generation + */ + protected TechniqueDef techniqueDef = null; + /** + * Extension pattern + */ + Pattern extensions = Pattern.compile("(#extension.*\\s+)"); + + private Map imports = new LinkedHashMap<>(); + + /** + * Build a shaderGenerator + * + * @param assetManager + */ + protected ShaderGenerator(AssetManager assetManager) { + this.assetManager = assetManager; + } + + public void initialize(TechniqueDef techniqueDef){ + this.techniqueDef = techniqueDef; + } + + /** + * Generate vertex and fragment shaders for the given technique + * + * @return a Shader program + */ + public Shader generateShader(String definesSourceCode) { + if (techniqueDef == null) { + throw new UnsupportedOperationException("The shaderGenerator was not " + + "properly initialized, call " + + "initialize(TechniqueDef) before any generation"); + } + + String techniqueName = techniqueDef.getName(); + ShaderGenerationInfo info = techniqueDef.getShaderGenerationInfo(); + + Shader shader = new Shader(); + for (ShaderType type : ShaderType.values()) { + String extension = type.getExtension(); + String language = getLanguageAndVersion(type); + String shaderSourceCode = buildShader(techniqueDef.getShaderNodes(), info, type); + + if (shaderSourceCode != null) { + String shaderSourceAssetName = techniqueName + "." + extension; + shader.addSource(type, shaderSourceAssetName, shaderSourceCode, definesSourceCode, language); + } + } + + techniqueDef = null; + return shader; + } + + /** + * This method is responsible for the shader generation. + * + * @param shaderNodes the list of shader nodes + * @param info the ShaderGenerationInfo filled during the Technique loading + * @param type the type of shader to generate + * @return the code of the generated vertex shader + */ + protected String buildShader(List shaderNodes, ShaderGenerationInfo info, ShaderType type) { + if (type == ShaderType.TessellationControl || + type == ShaderType.TessellationEvaluation || + type == ShaderType.Geometry) { + // TODO: Those are not supported. + // Too much code assumes that type is either Vertex or Fragment + return null; + } + + imports.clear(); + + indent = 0; + + StringBuilder sourceDeclaration = new StringBuilder(); + StringBuilder source = new StringBuilder(); + + generateUniforms(sourceDeclaration, info, type); + + if (type == ShaderType.Vertex) { + generateAttributes(sourceDeclaration, info); + } + generateVaryings(sourceDeclaration, info, type); + + generateStartOfMainSection(source, info, type); + + generateDeclarationAndMainBody(shaderNodes, sourceDeclaration, source, info, type); + + generateEndOfMainSection(source, info, type); + + //insert imports backward + int insertIndex = sourceDeclaration.length(); + for (String importSource : imports.values()) { + sourceDeclaration.insert(insertIndex, importSource); + } + + sourceDeclaration.append(source); + + return moveExtensionsUp(sourceDeclaration); + } + + /** + * parses the source and moves all the extensions at the top of the shader source as having extension declarations + * in the middle of a shader is against the specs and not supported by all drivers. + * @param sourceDeclaration + * @return + */ + private String moveExtensionsUp(StringBuilder sourceDeclaration) { + Matcher m = extensions.matcher( sourceDeclaration.toString()); + StringBuilder finalSource = new StringBuilder(); + while(m.find()){ + finalSource.append(m.group()); + } + finalSource.append(m.replaceAll("")); + return finalSource.toString(); + } + + /** + * iterates through shader nodes to load them and generate the shader + * declaration part and main body extracted from the shader nodes, for the + * given shader type + * + * @param shaderNodes the list of shader nodes + * @param sourceDeclaration the declaration part StringBuilder of the shader + * to generate + * @param source the main part StringBuilder of the shader to generate + * @param info the ShaderGenerationInfo + * @param type the Shader type + */ + protected void generateDeclarationAndMainBody(List shaderNodes, StringBuilder sourceDeclaration, StringBuilder source, ShaderGenerationInfo info, Shader.ShaderType type) { + for (ShaderNode shaderNode : shaderNodes) { + if (info.getUnusedNodes().contains(shaderNode.getName())) { + continue; + } + if (shaderNode.getDefinition().getType() == type) { + int index = findShaderIndexFromVersion(shaderNode, type); + String shaderPath = shaderNode.getDefinition().getShadersPath().get(index); + Map sources = (Map) assetManager.loadAsset(new ShaderAssetKey(shaderPath, false)); + String loadedSource = sources.get("[main]"); + for (String name : sources.keySet()) { + if (!name.equals("[main]")) { + imports.put(name, sources.get(name)); + } + } + appendNodeDeclarationAndMain(loadedSource, sourceDeclaration, source, shaderNode, info, shaderPath); + } + } + } + + /** + * Appends declaration and main part of a node to the shader declaration and + * main part. the loadedSource is split by "void main(){" to split + * declaration from main part of the node source code.The trailing "}" is + * removed from the main part. Each part is then respectively passed to + * generateDeclarativeSection and generateNodeMainSection. + * + * @see ShaderGenerator#generateDeclarativeSection + * @see ShaderGenerator#generateNodeMainSection + * + * @param loadedSource the actual source code loaded for this node. + * @param shaderPath path the the shader file + * @param sourceDeclaration the Shader declaration part string builder. + * @param source the Shader main part StringBuilder. + * @param shaderNode the shader node. + * @param info the ShaderGenerationInfo. + */ + protected void appendNodeDeclarationAndMain(String loadedSource, StringBuilder sourceDeclaration, StringBuilder source, ShaderNode shaderNode, ShaderGenerationInfo info, String shaderPath) { + if (loadedSource.length() > 1) { + loadedSource = loadedSource.substring(0, loadedSource.lastIndexOf("}")); + String[] sourceParts = loadedSource.split("\\s*void\\s*main\\s*\\(\\s*\\)\\s*\\{"); + if(sourceParts.length<2){ + throw new IllegalArgumentException("Syntax error in "+ shaderPath +". Cannot find 'void main(){' in \n"+ loadedSource); + } + generateDeclarativeSection(sourceDeclaration, shaderNode, sourceParts[0], info); + generateNodeMainSection(source, shaderNode, sourceParts[1], info); + } else { + //if source is empty, we still call generateNodeMainSection so that mappings can be done. + generateNodeMainSection(source, shaderNode, loadedSource, info); + } + + } + + /** + * returns the language + version of the shader should be something like + * "GLSL100" for glsl 1.0 "GLSL150" for glsl 1.5. + * + * @param type the shader type for which the version should be returned. + * + * @return the shaderLanguage and version. + */ + protected abstract String getLanguageAndVersion(Shader.ShaderType type); + + /** + * generates the uniforms declaration for a shader of the given type. + * + * @param source the source StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + * @param type the shader type the uniforms have to be generated for. + */ + protected abstract void generateUniforms(StringBuilder source, ShaderGenerationInfo info, ShaderType type); + + /** + * generates the attributes declaration for the vertex shader. There is no + * Shader type passed here as attributes are only used in vertex shaders + * + * @param source the source StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + */ + protected abstract void generateAttributes(StringBuilder source, ShaderGenerationInfo info); + + /** + * generates the varyings for the given shader type shader. Note that + * varyings are deprecated in glsl 1.3, but this method will still be called + * to generate all non global inputs and output of the shaders. + * + * @param source the source StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + * @param type the shader type the varyings have to be generated for. + */ + protected abstract void generateVaryings(StringBuilder source, ShaderGenerationInfo info, ShaderType type); + + /** + * Appends the given shaderNode declarative part to the shader declarative + * part. If needed the sahder type can be determined by fetching the + * shaderNode's definition type. + * + * @see ShaderNode#getDefinition() + * @see ShaderNodeDefinition#getType() + * + * @param nodeDecalarationSource the declaration part of the node + * @param source the StringBuilder to append generated code. + * @param shaderNode the shaderNode. + * @param info the ShaderGenerationInfo. + */ + protected abstract void generateDeclarativeSection(StringBuilder source, ShaderNode shaderNode, String nodeDecalarationSource, ShaderGenerationInfo info); + + /** + * generates the start of the shader main section. this method is + * responsible of appending the "void main(){" in the shader and declaring + * all global outputs of the shader + * + * @param source the StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + * @param type the shader type the section has to be generated for. + */ + protected abstract void generateStartOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type); + + /** + * generates the end of the shader main section. this method is responsible + * of appending the last "}" in the shader and mapping all global outputs of + * the shader + * + * @param source the StringBuilder to append generated code. + * @param info the ShaderGenerationInfo. + * @param type the shader type the section has to be generated for. + */ + protected abstract void generateEndOfMainSection(StringBuilder source, ShaderGenerationInfo info, ShaderType type); + + /** + * Appends the given shaderNode main part to the shader declarative part. If + * needed the shader type can be determined by fetching the shaderNode's + * definition type. + * + * @see ShaderNode#getDefinition() + * @see ShaderNodeDefinition#getType() + * + * @param source the StringBuilder to append generated code. + * @param shaderNode the shaderNode. + * @param nodeSource the declaration part of the loaded shaderNode source. + * @param info the ShaderGenerationInfo. + */ + protected abstract void generateNodeMainSection(StringBuilder source, ShaderNode shaderNode, String nodeSource, ShaderGenerationInfo info); + + /** + * returns the shaderpath index according to the version of the generator. + * This allow to select the higher version of the shader that the generator + * can handle + * + * @param shaderNode the shaderNode being processed + * @param type the shaderType + * @return the index of the shader path in ShaderNodeDefinition shadersPath + * list + * @throws NumberFormatException + */ + protected int findShaderIndexFromVersion(ShaderNode shaderNode, ShaderType type) throws NumberFormatException { + int index = 0; + List lang = shaderNode.getDefinition().getShadersLanguage(); + int genVersion = Integer.parseInt(getLanguageAndVersion(type).substring(4)); + int curVersion = 0; + for (int i = 0; i < lang.size(); i++) { + int version = Integer.parseInt(lang.get(i).substring(4)); + if (version > curVersion && version <= genVersion) { + curVersion = version; + index = i; + } + } + return index; + } +} diff --git a/src/main/java/com/jme3/shader/ShaderNode.java b/src/main/java/com/jme3/shader/ShaderNode.java index dbe0e60..c31b81a 100644 --- a/src/main/java/com/jme3/shader/ShaderNode.java +++ b/src/main/java/com/jme3/shader/ShaderNode.java @@ -61,16 +61,11 @@ public class ShaderNode implements Savable, Cloneable { private List outputMapping = new ArrayList<>(); /** - * The mapping with values of some input variables. - */ - private List valueMapping = new ArrayList<>(); - - /** - * creates a ShaderNode + * Creates a shader node. * - * @param name the name - * @param definition the ShaderNodeDefinition - * @param condition the condition to activate this node + * @param name the name. + * @param definition the shader node definition. + * @param condition the condition to activate this node. */ public ShaderNode(String name, ShaderNodeDefinition definition, String condition) { this.name = name; @@ -79,12 +74,13 @@ public ShaderNode(String name, ShaderNodeDefinition definition, String condition } /** - * creates a ShaderNode + * Creates a shader node. */ public ShaderNode() { } /** + * Gets the name of the node. * * @return the name of the node */ @@ -93,105 +89,88 @@ public String getName() { } /** - * sets the name of th node + * Sets the name of the node. * - * @param name the name + * @param name the name of the node. */ public void setName(String name) { this.name = name; } /** - * returns the definition + * Returns the shader node definition. * - * @return the ShaderNodeDefinition + * @return the shader node definition. */ public ShaderNodeDefinition getDefinition() { return definition; } /** - * sets the definition + * Sets the shader node definition. * - * @param definition the ShaderNodeDefinition + * @param definition the shader node definition. */ public void setDefinition(ShaderNodeDefinition definition) { this.definition = definition; } /** + * Gets the condition. * - * @return the condition + * @return the condition. */ public String getCondition() { return condition; } /** - * sets the condition + * Sets the condition. * - * @param condition the condition + * @param condition the condition. */ public void setCondition(String condition) { this.condition = condition; } /** - * return a list of VariableMapping representing the input mappings of this - * node + * Returns a list of variable mapping representing the input mappings of this + * node. * - * @return the input mappings + * @return the input mappings. */ public List getInputMapping() { return inputMapping; } /** - * sets the input mappings + * Sets the input mappings. * - * @param inputMapping the input mappings + * @param inputMapping the input mappings. */ public void setInputMapping(List inputMapping) { this.inputMapping = inputMapping; } /** - * return a list of VariableMapping representing the output mappings of this - * node + * Returns a list of variable mapping representing the output mappings of this + * node. * - * @return the output mappings + * @return the output mappings. */ public List getOutputMapping() { return outputMapping; } /** - * sets the output mappings + * Sets the output mappings. * - * @param outputMapping the output mappings + * @param outputMapping the output mappings. */ public void setOutputMapping(List outputMapping) { this.outputMapping = outputMapping; } - /** - * Gets the value mapping. - * - * @return the value mapping. - */ - public List getValueMapping() { - return valueMapping; - } - - /** - * Sets the value mapping. - * - * @param valueMapping the value mapping. - */ - public void setValueMapping(final List valueMapping) { - this.valueMapping = valueMapping; - } - /** * jme serialization * @@ -206,7 +185,6 @@ public void write(JmeExporter ex) throws IOException { oc.write(condition, "condition", null); oc.writeSavableArrayList((ArrayList) inputMapping, "inputMapping", new ArrayList()); oc.writeSavableArrayList((ArrayList) outputMapping, "outputMapping", new ArrayList()); - oc.writeSavableArrayList((ArrayList) valueMapping, "valueMapping", new ArrayList()); } /** @@ -223,7 +201,6 @@ public void read(JmeImporter im) throws IOException { condition = ic.readString("condition", null); inputMapping = (List) ic.readSavableArrayList("inputMapping", new ArrayList()); outputMapping = (List) ic.readSavableArrayList("outputMapping", new ArrayList()); - valueMapping = (List) ic.readSavableArrayList("valueMapping", new ArrayList()); } /** @@ -253,13 +230,6 @@ public String toString() { } } - if (!valueMapping.isEmpty()) { - builder.append("\n\tvalueMapping:\n"); - for (final ValueMapping mapping : valueMapping) { - builder.append("\t\t").append(mapping).append('\n'); - } - } - if (builder.charAt(builder.length() - 1) == '\n') { builder.delete(builder.length() - 1, builder.length()); } @@ -284,11 +254,6 @@ public ShaderNode clone() throws CloneNotSupportedException { clone.outputMapping.add(variableMapping.clone()); } - clone.valueMapping = new ArrayList<>(); - for (final ValueMapping valueMapping : valueMapping) { - clone.valueMapping.add(valueMapping.clone()); - } - return clone; } } diff --git a/src/main/java/com/jme3/shader/ValueMapping.java b/src/main/java/com/jme3/shader/ValueMapping.java deleted file mode 100644 index c89a5c3..0000000 --- a/src/main/java/com/jme3/shader/ValueMapping.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.jme3.shader; - -import com.jme3.export.*; - -import java.io.IOException; - -/** - * The mapping to define values of some input variables. - * - * @author JavaSaBr - */ -public class ValueMapping implements Savable, Cloneable { - - /** - * The variable. - */ - private ShaderNodeVariable variable; - - /** - * The value. - */ - private String value; - - public ValueMapping() { - } - - public ValueMapping(final ShaderNodeVariable variable) { - this.variable = variable; - } - - public ValueMapping(final ShaderNodeVariable variable, final String value) { - this.variable = variable; - this.value = value; - } - - /** - * Gets the variable. - * - * @return the variable. - */ - public ShaderNodeVariable getVariable() { - return variable; - } - - /** - * Sets the variable. - * - * @param variable the variable. - */ - public void setVariable(final ShaderNodeVariable variable) { - this.variable = variable; - } - - /** - * Sets the value. - * - * @param value the value. - */ - public void setValue(final String value) { - this.value = value; - } - - /** - * Gets the value. - * - * @return the value. - */ - public String getValue() { - return value; - } - - @Override - public ValueMapping clone() throws CloneNotSupportedException { - final ValueMapping clone = (ValueMapping) super.clone(); - clone.variable = variable == null ? null : variable.clone(); - return clone; - } - - @Override - public void write(final JmeExporter ex) throws IOException { - final OutputCapsule oc = ex.getCapsule(this); - oc.write(variable, "variable", null); - oc.write(value, "value", null); - } - - @Override - public void read(final JmeImporter im) throws IOException { - final InputCapsule ic = im.getCapsule(this); - variable = (ShaderNodeVariable) ic.readSavable("", null); - value = ic.readString("value", null); - } - - @Override - public String toString() { - return variable + " = '" + value + '\''; - } -} diff --git a/src/main/java/com/jme3/shader/VariableMapping.java b/src/main/java/com/jme3/shader/VariableMapping.java index eb287e6..93b138f 100644 --- a/src/main/java/com/jme3/shader/VariableMapping.java +++ b/src/main/java/com/jme3/shader/VariableMapping.java @@ -34,9 +34,10 @@ import com.jme3.export.*; import java.io.IOException; +import java.util.Objects; /** - * represents a mapping between 2 ShaderNodeVariables + * Represents a mapping between 2 shader node variables or a left shader node variable and a value expression. * * @author Nehon */ @@ -44,68 +45,91 @@ public class VariableMapping implements Savable, Cloneable { private ShaderNodeVariable leftVariable; private ShaderNodeVariable rightVariable; + private String rightExpression; private String condition; private String leftSwizzling = ""; private String rightSwizzling = ""; /** - * creates a VariableMapping + * Creates a VariableMapping. */ public VariableMapping() { } /** - * creates a VariableMapping + * Creates a VariableMapping. * - * @param leftVariable the left hand side variable of the expression - * @param leftSwizzling the swizzling of the left variable - * @param rightVariable the right hand side variable of the expression + * @param leftVariable the left hand side variable of the expression + * @param leftSwizzling the swizzling of the left variable + * @param rightVariable the right hand side variable of the expression * @param rightSwizzling the swizzling of the right variable - * @param condition the condition for this mapping + * @param condition the condition for this mapping */ - public VariableMapping(ShaderNodeVariable leftVariable, String leftSwizzling, ShaderNodeVariable rightVariable, String rightSwizzling, String condition) { + public VariableMapping(ShaderNodeVariable leftVariable, String leftSwizzling, ShaderNodeVariable rightVariable, + String rightSwizzling, String condition) { this.leftVariable = leftVariable; this.rightVariable = rightVariable; this.condition = condition; - this.leftSwizzling = leftSwizzling; - this.rightSwizzling = rightSwizzling; + this.leftSwizzling = Objects.requireNonNull(leftSwizzling); + this.rightSwizzling = Objects.requireNonNull(rightSwizzling); } /** + * Gets the left variable. * - * @return the left variable + * @return the left variable. */ public ShaderNodeVariable getLeftVariable() { return leftVariable; } /** - * sets the left variable + * Sets the left variable. * - * @param leftVariable the left variable + * @param leftVariable the left variable. */ public void setLeftVariable(ShaderNodeVariable leftVariable) { this.leftVariable = leftVariable; } /** + * Gets the right variable. * - * @return the right variable + * @return the right variable or null. */ public ShaderNodeVariable getRightVariable() { return rightVariable; } /** - * sets the right variable + * Sets the right variable. * - * @param rightVariable the right variable + * @param rightVariable the right variable. */ public void setRightVariable(ShaderNodeVariable rightVariable) { this.rightVariable = rightVariable; } /** + * Gets the right expression. + * + * @return the right expression or null. + */ + public String getRightExpression() { + return rightExpression; + } + + /** + * Sets the right expression. + * + * @param rightExpression the right expression. + */ + public void setRightExpression(final String rightExpression) { + this.rightExpression = rightExpression; + } + + /** + * Gets the condition. * * @return the condition */ @@ -114,46 +138,48 @@ public String getCondition() { } /** - * sets the condition + * Sets the condition. * - * @param condition the condition + * @param condition the condition or null. */ public void setCondition(String condition) { this.condition = condition; } /** + * Gets the left swizzle. * - * @return the left swizzle + * @return the left swizzle or empty string. */ public String getLeftSwizzling() { return leftSwizzling; } /** - * sets the left swizzle + * Sets the left swizzle. * - * @param leftSwizzling the left swizzle + * @param leftSwizzling the left swizzle. */ public void setLeftSwizzling(String leftSwizzling) { - this.leftSwizzling = leftSwizzling; + this.leftSwizzling = Objects.requireNonNull(leftSwizzling); } /** + * Gets the right swizzle. * - * @return the right swizzle + * @return the right swizzle or empty string. */ public String getRightSwizzling() { return rightSwizzling; } /** - * sets the right swizzle + * Sets the right swizzle. * - * @param rightSwizzling the right swizzle + * @param rightSwizzling the right swizzle. */ public void setRightSwizzling(String rightSwizzling) { - this.rightSwizzling = rightSwizzling; + this.rightSwizzling = Objects.requireNonNull(rightSwizzling); } /** @@ -164,9 +190,10 @@ public void setRightSwizzling(String rightSwizzling) { */ @Override public void write(JmeExporter ex) throws IOException { - OutputCapsule oc = (OutputCapsule) ex.getCapsule(this); + OutputCapsule oc = ex.getCapsule(this); oc.write(leftVariable, "leftVariable", null); oc.write(rightVariable, "rightVariable", null); + oc.write(rightExpression, "rightExpression", null); oc.write(condition, "condition", ""); oc.write(leftSwizzling, "leftSwizzling", ""); oc.write(rightSwizzling, "rightSwizzling", ""); @@ -180,9 +207,10 @@ public void write(JmeExporter ex) throws IOException { */ @Override public void read(JmeImporter im) throws IOException { - InputCapsule ic = (InputCapsule) im.getCapsule(this); + InputCapsule ic = im.getCapsule(this); leftVariable = (ShaderNodeVariable) ic.readSavable("leftVariable", null); rightVariable = (ShaderNodeVariable) ic.readSavable("rightVariable", null); + rightExpression = ic.readString("rightExpression", null); condition = ic.readString("condition", ""); leftSwizzling = ic.readString("leftSwizzling", ""); rightSwizzling = ic.readString("rightSwizzling", ""); @@ -190,18 +218,45 @@ public void read(JmeImporter im) throws IOException { @Override public String toString() { - return leftVariable.toString() + (leftSwizzling.length() > 0 ? ("." + leftSwizzling) : "") + " = " + - rightVariable.getType() + " " + rightVariable.getNameSpace() + "." + rightVariable.getName() + - (rightSwizzling.length() > 0 ? ("." + rightSwizzling) : "") + " : " + condition; + + final StringBuilder builder = new StringBuilder(leftVariable.toString()); + + if (!leftSwizzling.isEmpty()) { + builder.append('.').append(leftSwizzling); + } + + builder.append(" = "); + + if (rightVariable != null) { + + builder.append(rightVariable.getType()) + .append(' ') + .append(rightVariable.getNameSpace()) + .append('.') + .append(rightVariable.getName()); + + if (!rightSwizzling.isEmpty()) { + builder.append('.').append(rightSwizzling); + } + + } else if (rightExpression != null) { + builder.append(rightExpression); + } + + if (condition != null && !condition.isEmpty()) { + builder.append(" : ").append(condition); + } + + return builder.toString(); } @Override protected VariableMapping clone() throws CloneNotSupportedException { VariableMapping clone = (VariableMapping) super.clone(); - clone.leftVariable = leftVariable.clone(); - clone.rightVariable = rightVariable.clone(); - + if (rightVariable != null) { + clone.rightVariable = rightVariable.clone(); + } return clone; } } diff --git a/src/main/java/com/jme3/shader/glsl/AstShaderGenerator.java b/src/main/java/com/jme3/shader/glsl/AstShaderGenerator.java index e136ce4..5f9fa5a 100644 --- a/src/main/java/com/jme3/shader/glsl/AstShaderGenerator.java +++ b/src/main/java/com/jme3/shader/glsl/AstShaderGenerator.java @@ -523,7 +523,7 @@ protected void generateNodeMainSection(final StringBuilder source, final ShaderN // Variables fed with a sampler matparam or world param are replaced by the matparam itself // It avoids issue with samplers that have to be uniforms. - if (isWorldOrMaterialParam(rightVariable) && rightVariable.getType().startsWith("sampler")) { + if (rightVariable != null && isWorldOrMaterialParam(rightVariable) && rightVariable.getType().startsWith("sampler")) { nodeSource = replace(nodeSource, leftVariable, rightVariable.getPrefix() + rightVariable.getName()); } else { @@ -542,23 +542,6 @@ protected void generateNodeMainSection(final StringBuilder source, final ShaderN } } - final List valueMapping = shaderNode.getValueMapping(); - - for (final ValueMapping mapping : valueMapping) { - - final ShaderNodeVariable variable = mapping.getVariable(); - - String newName = shaderNode.getName() + "_" + variable.getName(); - if (declaredVariables.contains(newName)) { - continue; - } - - map(mapping, source); - - nodeSource = replace(nodeSource, variable, newName); - declaredVariables.add(newName); - } - for (final ShaderNodeVariable var : definition.getInputs()) { if (var.getDefaultValue() == null) { @@ -775,7 +758,7 @@ private void findAvailableDefinesToDefine(final ShaderNode shaderNode, final Lis for (final VariableMapping mapping : otherInputMapping) { final ShaderNodeVariable variable = mapping.getRightVariable(); - if (!shaderNode.getName().equals(variable.getNameSpace())) { + if (variable == null || !shaderNode.getName().equals(variable.getNameSpace())) { continue; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java index 1e7191e..c23828a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java @@ -994,6 +994,10 @@ private void buildLines(@NotNull final ObservableList children, @NotNull f final ShaderNodeVariable leftVariable = variableMapping.getLeftVariable(); final ShaderNodeVariable rightVariable = variableMapping.getRightVariable(); + if (rightVariable == null) { + continue; + } + final ShaderNodeParameter leftParameter = findByVariable(leftVariable, fromOutputMapping, true); final ShaderNodeParameter rightParameter = findByVariable(rightVariable, fromOutputMapping, false); From 3ea8acb0f8efabae2804c8673062c1220b1a7557 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Sat, 13 Jan 2018 22:38:20 +0300 Subject: [PATCH 07/25] updated compatibility. --- build.gradle | 4 + .../shader/nodes/ShaderNodesEditorPlugin.java | 8 +- .../model/shader/node/ShaderNodesProject.java | 10 +- .../model/shader/node/definition/SndList.java | 4 +- .../ui/component/SndDocumentationArea.java | 6 +- .../ShaderNodeDefinitionsFileCreator.java | 7 +- .../ShaderNodeDefinitionFileEditor.java | 49 +++---- .../editor/ShaderNodesChangeConsumer.java | 46 +++--- .../editor/ShaderNodesEditor3DState.java | 9 +- .../editor/ShaderNodesFileEditor.java | 133 +++++++++--------- .../editor/state/ShaderNodeState.java | 14 +- .../editor/state/ShaderNodeVariableState.java | 18 +-- .../editor/state/ShaderNodesEditorState.java | 10 +- .../editor/state/TechniqueDefState.java | 30 ++-- .../preview/CodePreviewComponent.java | 10 +- .../MaterialDefCodePreviewComponent.java | 6 +- .../FragmentShaderCodePreviewComponent.java | 4 +- .../shader/ShaderCodePreviewComponent.java | 22 +-- .../VertexShaderCodePreviewComponent.java | 4 +- .../shader/nodes/ShaderNodeElement.java | 50 +++---- .../shader/nodes/ShaderNodesContainer.java | 98 ++++++------- .../shader/nodes/action/ShaderNodeAction.java | 14 +- .../add/AddAttributeShaderNodeAction.java | 8 +- .../add/AddMaterialParamShaderNodeAction.java | 12 +- .../AddMaterialTextureShaderNodeAction.java | 8 +- .../action/add/AddNodeShaderNodeAction.java | 17 ++- ...TechniqueDefParameterShaderNodeAction.java | 10 +- .../add/AddWorldParamShaderNodeAction.java | 8 +- .../RemoveAttributeShaderNodeAction.java | 6 +- .../RemoveMaterialParamShaderNodeAction.java | 6 +- .../RemoveRelationShaderNodeAction.java | 6 +- .../action/remove/RemoveShaderNodeAction.java | 6 +- .../RemoveWorldParamShaderNodeAction.java | 6 +- .../nodes/global/GlobalShaderNodeElement.java | 4 +- .../global/InputGlobalShaderNodeElement.java | 8 +- .../global/OutputGlobalShaderNodeElement.java | 12 +- .../component/shader/nodes/line/TempLine.java | 6 +- .../shader/nodes/line/VariableLine.java | 10 +- .../main/AttributeShaderNodeElement.java | 8 +- .../nodes/main/FragmentShaderNodeElement.java | 4 +- .../nodes/main/MainShaderNodeElement.java | 14 +- .../nodes/main/MaterialShaderNodeElement.java | 20 +-- .../main/OutputVariableShaderNodeElement.java | 6 +- .../nodes/main/VariableShaderNodeElement.java | 6 +- .../nodes/main/VertexShaderNodeElement.java | 4 +- .../nodes/main/WorldShaderNodeElement.java | 8 +- .../operation/ChangeLightModeOperation.java | 8 +- .../nodes/operation/ShaderNodeOperation.java | 24 ++-- .../operation/add/AddAttributeOperation.java | 12 +- .../add/AddMaterialParameterOperation.java | 12 +- .../operation/add/AddShaderNodeOperation.java | 12 +- .../operation/add/AddTechniqueOperation.java | 12 +- .../add/AddWorldParameterOperation.java | 12 +- .../AttachAttributeToShaderNodeOperation.java | 6 +- .../AttachGlobalToShaderNodeOperation.java | 6 +- .../attach/AttachShaderNodeOperation.java | 8 +- .../AttachUniformToShaderNodeOperation.java | 6 +- .../AttachVarToGlobalNodeOperation.java | 6 +- .../AttachVarToShaderNodeOperation.java | 6 +- .../detach/DetachShaderNodeOperation.java | 14 +- .../InputDetachShaderNodeOperation.java | 4 +- .../OutputDetachShaderNodeOperation.java | 4 +- .../RemoveAttributeVariableOperation.java | 12 +- ...oveMaterialParameterVariableOperation.java | 12 +- .../remove/RemoveShaderNodeOperation.java | 12 +- .../RemoveUniformVariableOperation.java | 6 +- .../remove/RemoveVariableOperation.java | 6 +- ...RemoveWorldParameterVariableOperation.java | 12 +- .../EditableMaterialShaderNodeParameter.java | 8 +- .../parameter/InputShaderNodeParameter.java | 6 +- .../parameter/OutputShaderNodeParameter.java | 6 +- .../nodes/parameter/ShaderNodeParameter.java | 16 +-- .../parameter/socket/InputSocketElement.java | 8 +- .../parameter/socket/OutputSocketElement.java | 8 +- .../nodes/parameter/socket/SocketElement.java | 10 +- .../tooltip/SndDocumentationTooltip.java | 19 ++- .../ui/control/tree/action/AddSndAction.java | 12 +- .../action/AddSndInputParameterAction.java | 6 +- .../action/AddSndOutputParameterAction.java | 6 +- .../tree/action/AddSndParameterAction.java | 25 ++-- .../tree/action/AddSndShaderSourceAction.java | 12 +- .../control/tree/action/DeleteSndAction.java | 8 +- .../action/DeleteSndShaderSourceAction.java | 8 +- .../tree/action/DeleteSndarameterAction.java | 8 +- .../action/EditSndDocumentationAction.java | 8 +- .../factory/ShaderNodesTreeNodeFactory.java | 6 +- .../definition/SndDocumentationTreeNode.java | 6 +- .../tree/node/definition/SndListTreeNode.java | 10 +- .../node/definition/SndParameterTreeNode.java | 10 +- .../definition/SndParametersTreeNode.java | 10 +- .../definition/SndShaderSourceTreeNode.java | 6 +- .../definition/SndShaderSourcesTreeNode.java | 10 +- .../tree/node/definition/SndTreeNode.java | 14 +- .../tree/operation/AddSndOperation.java | 6 +- .../operation/AddSndParameterOperation.java | 6 +- .../AddSndShaderSourceOperation.java | 6 +- .../ChangeSndDocumentationOperation.java | 6 +- .../tree/operation/DeleteSndOperation.java | 6 +- .../DeleteSndParameterOperation.java | 6 +- .../DeleteSndShaderSourceOperation.java | 6 +- .../tree/operation/RenameSndOperation.java | 6 +- .../RenameSndParameterOperation.java | 6 +- .../property/ShaderNodesPropertyBuilder.java | 16 +-- .../ui/dialog/EditSndDocumentationDialog.java | 8 +- .../nodes/ui/preview/SndFilePreview.java | 26 ++-- .../ui/preview/SndFilePreviewFactory.java | 4 +- .../shader/nodes/util/ShaderNodeUtils.java | 4 +- 107 files changed, 666 insertions(+), 663 deletions(-) diff --git a/build.gradle b/build.gradle index cc3ba41..0b57279 100644 --- a/build.gradle +++ b/build.gradle @@ -53,6 +53,10 @@ configurations { pluginDependences } +javadoc { + failOnError = false +} + dependencies { compile 'com.github.JavaSaBr:jmonkeybuilder:develop-SNAPSHOT' diff --git a/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java b/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java index f5fb88f..6520b4c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java +++ b/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java @@ -3,10 +3,9 @@ import com.jme3.asset.AssetManager; import com.jme3.shader.glsl.AstGlsl150ShaderGenerator; import com.jme3.shader.glsl.AstShaderGenerator; -import com.ss.editor.Editor; import com.ss.editor.FileExtensions; -import com.ss.editor.annotation.FXThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.FileIconManager; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.EditorPlugin; @@ -23,6 +22,7 @@ import com.ss.editor.ui.control.tree.node.TreeNodeFactoryRegistry; import com.ss.editor.ui.css.CSSRegistry; import com.ss.editor.ui.preview.FilePreviewFactoryRegistry; +import com.ss.editor.util.EditorUtil; import com.ss.rlib.plugin.PluginContainer; import com.ss.rlib.plugin.PluginSystem; import com.ss.rlib.plugin.annotation.PluginDescription; @@ -53,11 +53,11 @@ public ShaderNodesEditorPlugin(@NotNull final PluginContainer pluginContainer) { public void onAfterCreateJMEContext(@NotNull final PluginSystem pluginSystem) { super.onAfterCreateJMEContext(pluginSystem); System.setProperty(AstShaderGenerator.PROP_USE_CASE, "false"); - final AssetManager assetManager = Editor.getInstance().getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); assetManager.setShaderGenerator(new AstGlsl150ShaderGenerator(assetManager)); } - @FXThread + @FxThread @Override public void onBeforeCreateJavaFXContext(@NotNull final PluginSystem pluginSystem) { super.onBeforeCreateJavaFXContext(pluginSystem); diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java index 5df646d..066ddfd 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java @@ -6,7 +6,7 @@ import com.jme3.util.clone.Cloner; import com.jme3.util.clone.JmeCloneable; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.state.TechniqueDefState; import com.ss.editor.util.EditorUtil; import org.jetbrains.annotations.NotNull; @@ -108,7 +108,7 @@ public void setMaterialDefContent(@NotNull final String materialDefContent) { } @Override - @JMEThread + @JmeThread public ShaderNodesProject jmeClone() { try { return (ShaderNodesProject) super.clone(); @@ -118,13 +118,13 @@ public ShaderNodesProject jmeClone() { } @Override - @JMEThread + @JmeThread public void cloneFields(@NotNull final Cloner cloner, @NotNull final Object original) { matParams = cloner.clone(matParams); } @Override - @JMEThread + @JmeThread public void write(@NotNull final JmeExporter ex) throws IOException { final byte[] techStates = EditorUtil.serialize(techniqueDefStates); @@ -136,7 +136,7 @@ public void write(@NotNull final JmeExporter ex) throws IOException { } @Override - @JMEThread + @JmeThread public void read(@NotNull final JmeImporter im) throws IOException { final InputCapsule in = im.getCapsule(this); diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java index cdbd83a..b79684d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.model.shader.node.definition; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -28,7 +28,7 @@ public SndList(@NotNull final List definitions) { * * @return the list of definitions. */ - @FXThread + @FxThread public @NotNull List getDefinitions() { return definitions; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/SndDocumentationArea.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/SndDocumentationArea.java index ef2fb39..e9a715c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/SndDocumentationArea.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/SndDocumentationArea.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.component; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.code.BaseCodeArea; import org.fxmisc.richtext.model.StyleSpans; import org.jetbrains.annotations.NotNull; @@ -32,13 +32,13 @@ public class SndDocumentationArea extends BaseCodeArea { ); @Override - @FXThread + @FxThread protected @NotNull String[][] getAvailableClasses() { return AVAILABLE_CLASSES; } @Override - @FXThread + @FxThread protected @NotNull StyleSpans> calculateStyleSpans(@NotNull final String text) { return computeHighlighting(PATTERN, text); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java index c461f02..8620913 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java @@ -9,7 +9,7 @@ import com.jme3.shader.Shader.ShaderType; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditablePropertyType; import com.ss.editor.plugin.api.file.creator.GenericFileCreator; @@ -82,7 +82,8 @@ public class ShaderNodeDefinitionsFileCreator extends GenericFileCreator { AVAILABLE_TYPES.add(ShaderType.Vertex.name()); AVAILABLE_TYPES.add(ShaderType.Fragment.name()); - final Renderer renderer = EDITOR.getRenderer(); + //FIXME + final Renderer renderer = JME_APPLICATION.getRenderer(); final EnumSet caps = renderer.getCaps(); caps.stream().filter(cap -> cap.name().startsWith("GLSL")) @@ -124,7 +125,7 @@ public class ShaderNodeDefinitionsFileCreator extends GenericFileCreator { } @Override - @FXThread + @FxThread protected void processOk() { super.hide(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java index 4dfbba4..209807a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java @@ -8,7 +8,7 @@ import com.jme3.shader.glsl.parser.GlslParser; import com.ss.editor.FileExtensions; import com.ss.editor.annotation.BackgroundThread; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -26,6 +26,7 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.editor.ui.css.CSSClasses; +import com.ss.editor.util.EditorUtil; import com.ss.rlib.ui.util.FXUtils; import com.ss.rlib.util.FileUtils; import com.ss.rlib.util.StringUtils; @@ -118,7 +119,7 @@ public ShaderNodeDefinitionFileEditor() { } @Override - @FXThread + @FxThread protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { super.createToolComponents(container, root); @@ -132,14 +133,14 @@ protected void createToolComponents(@NotNull final EditorToolComponent container FXUtils.addClassTo(structureTree.getTreeView(), CSSClasses.TRANSPARENT_TREE_VIEW); } - @FXThread + @FxThread @Override protected void calcVSplitSize(@NotNull final SplitPane splitPane) { splitPane.setDividerPosition(0, 0.6); } @Override - @FXThread + @FxThread protected void createEditorAreaPane() { super.createEditorAreaPane(); @@ -157,7 +158,7 @@ protected void createEditorAreaPane() { * * @return the code area. */ - @FXThread + @FxThread private @NotNull GLSLCodeArea getCodeArea() { return notNull(codeArea); } @@ -167,7 +168,7 @@ protected void createEditorAreaPane() { * * @param object the selected object. */ - @FXThread + @FxThread private void selectFromTree(@Nullable final Object object) { setEditedShader(null); @@ -218,7 +219,7 @@ private void selectFromTree(@Nullable final Object object) { * * @return the dictionary to store original GLSL code. */ - @FXThread + @FxThread private @NotNull ObjectDictionary getGlslOriginalContent() { return glslOriginalContent; } @@ -228,7 +229,7 @@ private void selectFromTree(@Nullable final Object object) { * * @return the dictionary to track changes of GLSL code. */ - @FXThread + @FxThread private @NotNull ObjectDictionary getGlslChangedContent() { return glslChangedContent; } @@ -238,7 +239,7 @@ private void selectFromTree(@Nullable final Object object) { * * @return the current edited shader. */ - @FXThread + @FxThread private @Nullable String getEditedShader() { return editedShader; } @@ -248,7 +249,7 @@ private void selectFromTree(@Nullable final Object object) { * * @param editedShader the current edited shader. */ - @FXThread + @FxThread private void setEditedShader(@Nullable final String editedShader) { this.editedShader = editedShader; } @@ -256,7 +257,7 @@ private void setEditedShader(@Nullable final String editedShader) { /** * @return true if need to ignore GLSL code changes. */ - @FXThread + @FxThread private boolean isIgnoreCodeChanges() { return ignoreCodeChanges; } @@ -264,7 +265,7 @@ private boolean isIgnoreCodeChanges() { /** * @param ignoreCodeChanges true if need to ignore GLSL code changes. */ - @FXThread + @FxThread private void setIgnoreCodeChanges(final boolean ignoreCodeChanges) { this.ignoreCodeChanges = ignoreCodeChanges; } @@ -274,7 +275,7 @@ private void setIgnoreCodeChanges(final boolean ignoreCodeChanges) { * * @param glslCode the new GLSL code. */ - @FXThread + @FxThread private void changeGLSLCode(@NotNull final String glslCode) { if (isIgnoreCodeChanges()) return; @@ -300,7 +301,7 @@ private void changeGLSLCode(@NotNull final String glslCode) { * @param shaderPath the shader path. * @return the GLSL code. */ - @FXThread + @FxThread private @NotNull String getGLSLCode(@NotNull final String shaderPath) { final ObjectDictionary glslChangedContent = getGlslChangedContent(); @@ -328,7 +329,7 @@ private void changeGLSLCode(@NotNull final String glslCode) { } @Override - @FXThread + @FxThread protected void doOpenFile(@NotNull final Path file) throws IOException { super.doOpenFile(file); @@ -337,7 +338,7 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(assetPath); key.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); definitionList = assetManager.loadAsset(key); @@ -395,7 +396,7 @@ protected void doSave(@NotNull final Path toStore) throws IOException { * * @return the structure tree. */ - @FXThread + @FxThread private @NotNull NodeTree getStructureTree() { return notNull(structureTree); } @@ -405,26 +406,26 @@ protected void doSave(@NotNull final Path toStore) throws IOException { * * @return the property editor. */ - @FXThread + @FxThread private @NotNull PropertyEditor getPropertyEditor() { return notNull(propertyEditor); } @Override - @FXThread + @FxThread protected boolean needToolbar() { return true; } @Override - @FXThread + @FxThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); FXUtils.addToPane(createSaveAction(), container); } @Override - @FXThread + @FxThread protected @Nullable Supplier getEditorStateFactory() { return ShaderNodeDefinitionEditorState::new; } @@ -436,7 +437,7 @@ protected void createToolbar(@NotNull final HBox container) { } @Override - @FXThread + @FxThread public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index, final boolean needSelect) { @@ -449,13 +450,13 @@ public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Obje } @Override - @FXThread + @FxThread public void notifyFXRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { getStructureTree().notifyRemoved(parent, removed); } @Override - @FXThread + @FxThread public void notifyFXChangeProperty(@Nullable final Object parent, @NotNull final Object object, @NotNull final String propertyName) { super.notifyFXChangeProperty(parent, object, propertyName); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java index 8517081..f48442e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java @@ -9,7 +9,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param shaderNode the shader nodes. * @param mapping the variable mapping. */ - @FXThread + @FxThread void notifyAddedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping); /** @@ -49,7 +49,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param shaderNode the shader nodes. * @param mapping the variable mapping. */ - @FXThread + @FxThread void notifyRemovedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping); /** @@ -59,7 +59,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param oldMapping the old variable mapping. * @param newMapping the new variable mapping. */ - @FXThread + @FxThread void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping oldMapping, @NotNull final VariableMapping newMapping); @@ -69,7 +69,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param matParam the material parameter. * @param location the location. */ - @FXThread + @FxThread void notifyAddedMatParameter(@NotNull final MatParam matParam, @NotNull Vector2f location); /** @@ -77,7 +77,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * * @param matParam the material parameter. */ - @FXThread + @FxThread void notifyRemovedMatParameter(@NotNull final MatParam matParam); /** @@ -86,7 +86,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param variable the variable of the attribute. * @param location the location. */ - @FXThread + @FxThread void notifyAddedAttribute(@NotNull final ShaderNodeVariable variable, @NotNull Vector2f location); /** @@ -94,7 +94,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * * @param variable the variable of the attribute. */ - @FXThread + @FxThread void notifyRemovedAttribute(@NotNull final ShaderNodeVariable variable); /** @@ -103,7 +103,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param binding the binding. * @param location the location. */ - @FXThread + @FxThread void notifyAddedWorldParameter(@NotNull final UniformBinding binding, @NotNull Vector2f location); /** @@ -111,7 +111,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * * @param binding the binding. */ - @FXThread + @FxThread void notifyRemovedWorldParameter(@NotNull final UniformBinding binding); /** @@ -120,7 +120,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param shaderNode the shader nodes. * @param location the location. */ - @FXThread + @FxThread void notifyAddedShaderNode(@NotNull final ShaderNode shaderNode, @NotNull Vector2f location); /** @@ -128,7 +128,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * * @param shaderNode the shader nodes. */ - @FXThread + @FxThread void notifyRemovedRemovedShaderNode(@NotNull final ShaderNode shaderNode); /** @@ -138,7 +138,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param location the location. * @param width the width. */ - @FXThread + @FxThread void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location, final double width); @@ -149,7 +149,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param location the location. * @param width the width. */ - @FXThread + @FxThread void notifyChangeState(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location, final double width); /** @@ -159,7 +159,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param location the location. * @param width the width. */ - @FXThread + @FxThread void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vector2f location, final double width); /** @@ -168,7 +168,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param shaderNode the shader nodes. * @return the location or null. */ - @FXThread + @FxThread @Nullable Vector2f getLocation(@NotNull final ShaderNode shaderNode); /** @@ -177,7 +177,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param variable the shader nodes variable. * @return the location or null. */ - @FXThread + @FxThread @Nullable Vector2f getLocation(@NotNull final ShaderNodeVariable variable); /** @@ -186,7 +186,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param input true if it's input global nodes. * @return the location or null. */ - @FXThread + @FxThread @Nullable Vector2f getGlobalNodeLocation(final boolean input); /** @@ -195,7 +195,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param shaderNode the shader nodes. * @return the width or 0. */ - @FXThread + @FxThread double getWidth(@NotNull final ShaderNode shaderNode); /** @@ -204,7 +204,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param variable the shader nodes variable. * @return the width or null. */ - @FXThread + @FxThread double getWidth(@NotNull final ShaderNodeVariable variable); /** @@ -213,7 +213,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param input true if it's input global nodes. * @return the width or null. */ - @FXThread + @FxThread double getGlobalNodeWidth(final boolean input); /** @@ -221,7 +221,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * * @param techniqueDef the technique definition. */ - @FXThread + @FxThread void notifyAddedTechnique(@NotNull final TechniqueDef techniqueDef); /** @@ -229,6 +229,6 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * * @param techniqueDef the technique definition. */ - @FXThread + @FxThread void notifyRemovedTechnique(@NotNull final TechniqueDef techniqueDef); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java index 179b5fb..24b085e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java @@ -2,7 +2,7 @@ import com.jme3.material.Material; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState; import org.jetbrains.annotations.NotNull; @@ -25,7 +25,7 @@ public ShaderNodesEditor3DState(@NotNull final ShaderNodesFileEditor fileEditor) */ @FromAnyThread public void selectTechnique(@NotNull final Material material, @NotNull final String name) { - EXECUTOR_MANAGER.addJMETask(() -> selectTechniqueImpl(material, name)); + EXECUTOR_MANAGER.addJmeTask(() -> selectTechniqueImpl(material, name)); } /** @@ -34,9 +34,10 @@ public void selectTechnique(@NotNull final Material material, @NotNull final Str * @param material the material. * @param name the name. */ - @JMEThread + @JmeThread private void selectTechniqueImpl(@NotNull final Material material, @NotNull final String name) { - material.selectTechnique(name, EDITOR.getRenderManager()); + //FIXME + material.selectTechnique(name, JME_APPLICATION.getRenderManager()); updateMaterialImpl(material); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index 4b59954..adccbf1 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -14,6 +14,7 @@ import com.jme3.material.plugin.export.materialdef.J3mdExporter; import com.jme3.material.plugins.J3MLoader; import com.jme3.math.Vector2f; +import com.jme3.renderer.RenderManager; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; @@ -21,7 +22,7 @@ import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.annotation.BackgroundThread; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; @@ -183,23 +184,23 @@ public class ShaderNodesFileEditor extends private boolean ignoreLightModeChanges; @Override - @FXThread + @FxThread protected @NotNull ShaderNodesEditor3DState create3DEditorState() { return new ShaderNodesEditor3DState(this); } @Override - @FXThread + @FxThread protected @Nullable Supplier getEditorStateFactory() { return ShaderNodesEditorState::new; } @Override - @FXThread + @FxThread protected void doOpenFile(@NotNull final Path file) throws IOException { super.doOpenFile(file); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final BinaryImporter importer = BinaryImporter.getInstance(); importer.setAssetManager(assetManager); @@ -238,18 +239,18 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { }); setMaterialDef(materialDef); - getEditor3DState().updateMaterial(EDITOR.getDefaultMaterial()); + getEditor3DState().updateMaterial(JME_APPLICATION.getDefaultMaterial()); final ShaderNodesEditor3DState editor3DState = getEditor3DState(); editor3DState.changeMode(ModelType.BOX); } @Override - @FXThread + @FxThread protected void loadState() { super.loadState(); - EXECUTOR_MANAGER.addFXTask(this::buildMaterial); + EXECUTOR_MANAGER.addFxTask(this::buildMaterial); final ShaderNodesEditorState editorState = getEditorState(); if (editorState == null) { @@ -298,7 +299,7 @@ protected void doSave(@NotNull final Path toStore) throws IOException { } @Override - @FXThread + @FxThread protected void createEditorAreaPane() { super.createEditorAreaPane(); @@ -320,17 +321,21 @@ protected void createEditorAreaPane() { } @Override - @FXThread + @FxThread protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { super.createToolComponents(container, root); - fragmentPreview = new FragmentShaderCodePreviewComponent(EDITOR.getAssetManager(), EDITOR.getRenderManager()); + final AssetManager assetManager = EditorUtil.getAssetManager(); + //FIXME + final RenderManager renderManager = JME_APPLICATION.getRenderManager(); + + fragmentPreview = new FragmentShaderCodePreviewComponent(assetManager, renderManager); fragmentPreview.prefHeightProperty().bind(root.heightProperty()); - vertexPreview = new VertexShaderCodePreviewComponent(EDITOR.getAssetManager(), EDITOR.getRenderManager()); + vertexPreview = new VertexShaderCodePreviewComponent(assetManager, renderManager); vertexPreview.prefHeightProperty().bind(root.heightProperty()); - matDefPreview = new MaterialDefCodePreviewComponent(EDITOR.getAssetManager(), EDITOR.getRenderManager()); + matDefPreview = new MaterialDefCodePreviewComponent(assetManager, renderManager); matDefPreview.prefHeightProperty().bind(root.heightProperty()); container.addComponent(vertexPreview, PluginMessages.SNS_EDITOR_TOOL_VERTEX); @@ -359,7 +364,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container * * @return the fragment preview component. */ - @FXThread + @FxThread private @NotNull ShaderCodePreviewComponent getFragmentPreview() { return notNull(fragmentPreview); } @@ -369,7 +374,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container * * @return the vertex preview component. */ - @FXThread + @FxThread private @NotNull ShaderCodePreviewComponent getVertexPreview() { return notNull(vertexPreview); } @@ -379,13 +384,13 @@ protected void createToolComponents(@NotNull final EditorToolComponent container * * @return the material definition preview component. */ - @FXThread + @FxThread private @NotNull MaterialDefCodePreviewComponent getMatDefPreview() { return notNull(matDefPreview); } @Override - @FXThread + @FxThread protected void createActions(@NotNull final HBox container) { super.createActions(container); @@ -406,7 +411,7 @@ protected void createActions(@NotNull final HBox container) { } @Override - @FXThread + @FxThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); @@ -441,7 +446,7 @@ protected void createToolbar(@NotNull final HBox container) { /** * Add new technique. */ - @FXThread + @FxThread private void addTechnique() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); @@ -452,7 +457,7 @@ private void addTechnique() { dialog.show(); } - @FXThread + @FxThread private boolean validateTechnique(@NotNull final VarTable vars) { final String name = vars.getString(PROP_TECHNIQUE_NAME); final MaterialDef materialDef = getMaterialDef(); @@ -460,7 +465,7 @@ private boolean validateTechnique(@NotNull final VarTable vars) { return techniqueDefs == null && !name.isEmpty(); } - @FXThread + @FxThread private void addTechnique(@NotNull final VarTable vars) { final ShaderNodeVariable vertexGlobal = new ShaderNodeVariable("vec4", "Global", "position", null, ""); @@ -514,7 +519,7 @@ private void addTechnique(@NotNull final VarTable vars) { /** * Export the result material definition as a file. */ - @FXThread + @FxThread private void export() { UIUtils.openSaveAsDialog(this::export, FileExtensions.JME_MATERIAL_DEFINITION, ACTION_TESTER); } @@ -522,7 +527,7 @@ private void export() { /** * Import other material definition file to this project. */ - @FXThread + @FxThread private void importMatDef() { final ResourceManager resourceManager = ResourceManager.getInstance(); final Array resources = resourceManager.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION); @@ -535,7 +540,7 @@ private void importMatDef() { * @param assetPath the asset path. * @return the message or null if it's ok. */ - @FXThread + @FxThread private String validateMatDef(@NotNull final String assetPath) { final String message = StringVirtualAssetEditorDialog.DEFAULT_VALIDATOR.apply(assetPath); @@ -543,7 +548,7 @@ private String validateMatDef(@NotNull final String assetPath) { return message; } - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final MaterialDef materialDef = (MaterialDef) assetManager.loadAsset(assetPath); final Collection techniqueDefsNames = materialDef.getTechniqueDefsNames(); @@ -564,7 +569,7 @@ private String validateMatDef(@NotNull final String assetPath) { * * @param path the file. */ - @FXThread + @FxThread private void export(@NotNull final Path path) { final J3mdExporter exporter = new J3mdExporter(); @@ -584,10 +589,10 @@ private void export(@NotNull final Path path) { * * @param resource the resource. */ - @FXThread + @FxThread private void importMatDef(@NotNull final String resource) { - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final MaterialDef matDef = (MaterialDef) assetManager.loadAsset(resource); setMaterialDef(matDef); @@ -599,7 +604,7 @@ private void importMatDef(@NotNull final String resource) { * * @return the light modes combo box. */ - @FXThread + @FxThread private @NotNull ComboBox getLightModeComboBox() { return notNull(lightModeComboBox); } @@ -607,7 +612,7 @@ private void importMatDef(@NotNull final String resource) { /** * @return true if need to skip changes of light modes. */ - @FXThread + @FxThread private boolean isIgnoreLightModeChanges() { return ignoreLightModeChanges; } @@ -615,7 +620,7 @@ private boolean isIgnoreLightModeChanges() { /** * @param ignoreLightModeChanges true if need to skip changes of light modes. */ - @FXThread + @FxThread private void setIgnoreLightModeChanges(final boolean ignoreLightModeChanges) { this.ignoreLightModeChanges = ignoreLightModeChanges; } @@ -623,7 +628,7 @@ private void setIgnoreLightModeChanges(final boolean ignoreLightModeChanges) { /** * Handle changing the technique. */ - @FXThread + @FxThread private void changeTechnique(@Nullable final String newValue) { final Material currentMaterial = getCurrentMaterial(); @@ -670,7 +675,7 @@ private void changeTechnique(@Nullable final String newValue) { /** * Handle changing the light mode of this current technique. */ - @FXThread + @FxThread private void changeLightMode(@Nullable final LightMode prevLightMode, @Nullable final LightMode newLightMode) { if (isIgnoreLightModeChanges() || prevLightMode == null || newLightMode == null) return; @@ -683,7 +688,7 @@ private void changeLightMode(@Nullable final LightMode prevLightMode, @Nullable /** * @return the project file. */ - @FXThread + @FxThread private @NotNull ShaderNodesProject getProject() { return notNull(project); } @@ -691,7 +696,7 @@ private void changeLightMode(@Nullable final LightMode prevLightMode, @Nullable /** * @param project the project file. */ - @FXThread + @FxThread private void setProject(@NotNull final ShaderNodesProject project) { this.project = project; } @@ -699,7 +704,7 @@ private void setProject(@NotNull final ShaderNodesProject project) { /** * @return the current built material. */ - @FXThread + @FxThread private @Nullable Material getCurrentMaterial() { return currentMaterial; } @@ -707,7 +712,7 @@ private void setProject(@NotNull final ShaderNodesProject project) { /** * @param currentMaterial the current built material. */ - @FXThread + @FxThread private void setCurrentMaterial(@Nullable final Material currentMaterial) { this.currentMaterial = currentMaterial; } @@ -717,7 +722,7 @@ private void setCurrentMaterial(@Nullable final Material currentMaterial) { * * @param materialDef the current edited material definition. */ - @FXThread + @FxThread private void setMaterialDef(@NotNull final MaterialDef materialDef) { this.materialDef = materialDef; } @@ -737,7 +742,7 @@ private void setMaterialDef(@NotNull final MaterialDef materialDef) { /** * Build material for shader nodes. */ - @FXThread + @FxThread private void buildMaterial() { final Material currentMaterial = getCurrentMaterial(); @@ -797,7 +802,7 @@ private void buildMaterial() { final Collection materialParams = materialDef.getMaterialParams(); final Collection techniqueDefsNames = materialDef.getTechniqueDefsNames(); - final MaterialDef newMaterialDef = new MaterialDef(EDITOR.getAssetManager(), materialDef.getAssetName()); + final MaterialDef newMaterialDef = new MaterialDef(EditorUtil.getAssetManager(), materialDef.getAssetName()); materialParams.stream() .filter(MatParamTexture.class::isInstance) @@ -827,7 +832,7 @@ private void buildMaterial() { } @Override - @FXThread + @FxThread public void notifyAddedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -835,7 +840,7 @@ public void notifyAddedMapping(@NotNull final ShaderNode shaderNode, @NotNull fi } @Override - @FXThread + @FxThread public void notifyRemovedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -843,7 +848,7 @@ public void notifyRemovedMapping(@NotNull final ShaderNode shaderNode, @NotNull } @Override - @FXThread + @FxThread public void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping oldMapping, @NotNull final VariableMapping newMapping) { buildMaterial(); @@ -851,7 +856,7 @@ public void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull container.refreshLines(); } - @FXThread + @FxThread @Override public void notifyAddedMatParameter(@NotNull final MatParam matParam, @NotNull final Vector2f location) { buildMaterial(); @@ -859,7 +864,7 @@ public void notifyAddedMatParameter(@NotNull final MatParam matParam, @NotNull f container.addMatParam(matParam, location); } - @FXThread + @FxThread @Override public void notifyRemovedMatParameter(@NotNull final MatParam matParam) { buildMaterial(); @@ -867,7 +872,7 @@ public void notifyRemovedMatParameter(@NotNull final MatParam matParam) { container.removeMatParam(matParam); } - @FXThread + @FxThread @Override public void notifyAddedAttribute(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location) { buildMaterial(); @@ -875,7 +880,7 @@ public void notifyAddedAttribute(@NotNull final ShaderNodeVariable variable, @No container.addNodeElement(variable, location); } - @FXThread + @FxThread @Override public void notifyRemovedAttribute(@NotNull final ShaderNodeVariable variable) { buildMaterial(); @@ -884,7 +889,7 @@ public void notifyRemovedAttribute(@NotNull final ShaderNodeVariable variable) { } @Override - @FXThread + @FxThread public void notifyAddedWorldParameter(@NotNull final UniformBinding binding, @NotNull final Vector2f location) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -892,7 +897,7 @@ public void notifyAddedWorldParameter(@NotNull final UniformBinding binding, @No } @Override - @FXThread + @FxThread public void notifyRemovedWorldParameter(@NotNull final UniformBinding binding) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -900,7 +905,7 @@ public void notifyRemovedWorldParameter(@NotNull final UniformBinding binding) { } @Override - @FXThread + @FxThread public void notifyAddedShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -908,7 +913,7 @@ public void notifyAddedShaderNode(@NotNull final ShaderNode shaderNode, @NotNull } @Override - @FXThread + @FxThread public void notifyRemovedRemovedShaderNode(@NotNull final ShaderNode shaderNode) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -916,7 +921,7 @@ public void notifyRemovedRemovedShaderNode(@NotNull final ShaderNode shaderNode) } @Override - @FXThread + @FxThread public void notifyChangeState(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location, final double width) { @@ -926,7 +931,7 @@ public void notifyChangeState(@NotNull final ShaderNode shaderNode, @NotNull fin } @Override - @FXThread + @FxThread public void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location, final double width) { @@ -936,7 +941,7 @@ public void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNu } @Override - @FXThread + @FxThread public @Nullable Vector2f getLocation(@NotNull final ShaderNode shaderNode) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return null; @@ -945,7 +950,7 @@ public void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNu } @Override - @FXThread + @FxThread public @Nullable Vector2f getLocation(@NotNull final ShaderNodeVariable variable) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return null; @@ -954,7 +959,7 @@ public void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNu } @Override - @FXThread + @FxThread public double getWidth(@NotNull final ShaderNode shaderNode) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return 0D; @@ -963,7 +968,7 @@ public double getWidth(@NotNull final ShaderNode shaderNode) { } @Override - @FXThread + @FxThread public double getWidth(@NotNull final ShaderNodeVariable variable) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return 0D; @@ -972,7 +977,7 @@ public double getWidth(@NotNull final ShaderNodeVariable variable) { } @Override - @FXThread + @FxThread public @Nullable Vector2f getGlobalNodeLocation(final boolean input) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return null; @@ -980,7 +985,7 @@ public double getWidth(@NotNull final ShaderNodeVariable variable) { } @Override - @FXThread + @FxThread public double getGlobalNodeWidth(final boolean input) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return 0D; @@ -988,19 +993,19 @@ public double getGlobalNodeWidth(final boolean input) { } @Override - @FXThread + @FxThread public void notifyAddedTechnique(@NotNull final TechniqueDef techniqueDef) { buildMaterial(); } @Override - @FXThread + @FxThread public void notifyRemovedTechnique(@NotNull final TechniqueDef techniqueDef) { buildMaterial(); } @Override - @FXThread + @FxThread public void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vector2f location, final double width) { final TechniqueDefState state = getTechniqueDefState(); @@ -1020,7 +1025,7 @@ public void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vect * * @return the current technique definition state. */ - @FXThread + @FxThread private @Nullable TechniqueDefState getTechniqueDefState() { final ShaderNodesEditorState editorState = getEditorState(); @@ -1035,7 +1040,7 @@ public void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vect } @Override - @FXThread + @FxThread public void notifyFXChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { super.notifyFXChangeProperty(object, propertyName); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java index e6118b4..e965f13 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.editor.state; import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.editor.state.impl.AbstractEditorState; import org.jetbrains.annotations.NotNull; @@ -50,7 +50,7 @@ public ShaderNodeState(@NotNull final String name, @NotNull final Vector2f locat * * @return the name of a shader nodes. */ - @FXThread + @FxThread public @NotNull String getName() { return name; } @@ -60,7 +60,7 @@ public ShaderNodeState(@NotNull final String name, @NotNull final Vector2f locat * * @param name the name of a shader nodes. */ - @FXThread + @FxThread public void setName(@NotNull final String name) { this.name = name; } @@ -70,7 +70,7 @@ public void setName(@NotNull final String name) { * * @return the location of a shader nodes. */ - @FXThread + @FxThread public @NotNull Vector2f getLocation() { return location; } @@ -80,7 +80,7 @@ public void setName(@NotNull final String name) { * * @param location the location of a shader nodes. */ - @FXThread + @FxThread public void setLocation(@NotNull final Vector2f location) { this.location = location; } @@ -90,7 +90,7 @@ public void setLocation(@NotNull final Vector2f location) { * * @return the width of a shader nodes. */ - @FXThread + @FxThread public int getWidth() { return width; } @@ -100,7 +100,7 @@ public int getWidth() { * * @param width the width of a shader nodes. */ - @FXThread + @FxThread public void setWidth(final int width) { this.width = width; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java index 2619bec..06d1894 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.editor.state; import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.editor.state.impl.AbstractEditorState; import org.jetbrains.annotations.NotNull; @@ -60,7 +60,7 @@ public ShaderNodeVariableState(@NotNull final String name, @NotNull final String * * @return the name of a variable. */ - @FXThread + @FxThread public @NotNull String getName() { return name; } @@ -70,7 +70,7 @@ public ShaderNodeVariableState(@NotNull final String name, @NotNull final String * * @param name the name of a variable. */ - @FXThread + @FxThread public void setName(@NotNull final String name) { this.name = name; } @@ -80,7 +80,7 @@ public void setName(@NotNull final String name) { * * @return the namespace of a variable. */ - @FXThread + @FxThread public @NotNull String getNameSpace() { return nameSpace; } @@ -90,7 +90,7 @@ public void setName(@NotNull final String name) { * * @param nameSpace the namespace of a variable. */ - @FXThread + @FxThread public void setNameSpace(@NotNull final String nameSpace) { this.nameSpace = nameSpace; } @@ -100,7 +100,7 @@ public void setNameSpace(@NotNull final String nameSpace) { * * @return the location of a variable. */ - @FXThread + @FxThread public @NotNull Vector2f getLocation() { return location; } @@ -110,7 +110,7 @@ public void setNameSpace(@NotNull final String nameSpace) { * * @param location the location of a variable. */ - @FXThread + @FxThread public void setLocation(@NotNull final Vector2f location) { this.location = location; } @@ -120,7 +120,7 @@ public void setLocation(@NotNull final Vector2f location) { * * @return the width of a variable. */ - @FXThread + @FxThread public int getWidth() { return width; } @@ -130,7 +130,7 @@ public int getWidth() { * * @param width the width of a variable. */ - @FXThread + @FxThread public void setWidth(final int width) { this.width = width; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java index bdd69a1..8be4555 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.material.MaterialDef; import com.jme3.material.TechniqueDef; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesFileEditor; import com.ss.editor.ui.component.editor.state.impl.EditorMaterialEditorState; import com.ss.rlib.logging.Logger; @@ -42,13 +42,13 @@ public ShaderNodesEditorState() { * * @return the states of technique definitions. */ - @FXThread + @FxThread public @NotNull List getTechniqueDefStates() { return techniqueDefStates; } @Override - @FXThread + @FxThread public void setChangeHandler(@NotNull final Runnable changeHandler) { super.setChangeHandler(changeHandler); techniqueDefStates.forEach(state -> state.setChangeHandler(changeHandler)); @@ -60,7 +60,7 @@ public void setChangeHandler(@NotNull final Runnable changeHandler) { * @param techniqueDefName the name of a technique definition. * @return the state. */ - @FXThread + @FxThread public @NotNull TechniqueDefState getState(@NotNull final String techniqueDefName) { final Optional result = techniqueDefStates.stream() @@ -85,7 +85,7 @@ public void setChangeHandler(@NotNull final Runnable changeHandler) { * * @param materialDef the material definition. */ - @FXThread + @FxThread public void cleanUp(@NotNull final MaterialDef materialDef) { LOGGER.debug(this, editorState -> "The state before cleanup: " + editorState); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java index 23e881e..6982a7c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java @@ -8,7 +8,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.AttributeShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MaterialShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.WorldShaderNodeElement; @@ -92,7 +92,7 @@ public TechniqueDefState(@NotNull final String name) { * @param materialDef the material definition. * @param techniqueDef the technique definition. */ - @FXThread + @FxThread public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final TechniqueDef techniqueDef) { for (final Iterator iterator = shaderVariableStates.iterator(); iterator.hasNext(); ) { @@ -147,7 +147,7 @@ public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final Techn * @param location the location. * @param width the width. */ - @FXThread + @FxThread public void notifyChange(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location, final double width) { @@ -179,7 +179,7 @@ public void notifyChange(@NotNull final ShaderNodeVariable variable, @NotNull fi * @param location the location. * @param width the width. */ - @FXThread + @FxThread public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location, final double width) { @@ -208,7 +208,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * @param shaderNode the shader nodes. * @return the state or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeState getState(@NotNull final ShaderNode shaderNode) { return shaderNodeStates.stream().filter(variableState -> variableState.getName().equals(shaderNode.getName())) .findAny().orElse(null); @@ -220,7 +220,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * @param variable the shader nodes variable. * @return the state or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeVariableState getState(@Nullable final ShaderNodeVariable variable) { if (variable == null) return null; return shaderVariableStates.stream() @@ -234,7 +234,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * * @return the name of technique definition. */ - @FXThread + @FxThread public @NotNull String getName() { return name; } @@ -244,7 +244,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * * @return the location of input nodes. */ - @FXThread + @FxThread public @NotNull Vector2f getInputNodeLocation() { return inputNodeLocation; } @@ -254,7 +254,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * * @return the location of output nodes. */ - @FXThread + @FxThread public @NotNull Vector2f getOutputNodeLocation() { return outputNodeLocation; } @@ -264,7 +264,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * * @param inputNodeLocation the location of input nodes. */ - @FXThread + @FxThread public void setInputNodeLocation(@NotNull final Vector2f inputNodeLocation) { final Vector2f prev = getInputNodeLocation(); this.inputNodeLocation = inputNodeLocation; @@ -276,7 +276,7 @@ public void setInputNodeLocation(@NotNull final Vector2f inputNodeLocation) { * * @param outputNodeLocation the location of output nodes. */ - @FXThread + @FxThread public void setOutputNodeLocation(@NotNull final Vector2f outputNodeLocation) { final Vector2f prev = getOutputNodeLocation(); this.outputNodeLocation = outputNodeLocation; @@ -288,7 +288,7 @@ public void setOutputNodeLocation(@NotNull final Vector2f outputNodeLocation) { * * @return the width of output nodes. */ - @FXThread + @FxThread public int getOutputNodeWidth() { return outputNodeWidth; } @@ -298,7 +298,7 @@ public int getOutputNodeWidth() { * * @return the width of input nodes. */ - @FXThread + @FxThread public int getInputNodeWidth() { return inputNodeWidth; } @@ -308,7 +308,7 @@ public int getInputNodeWidth() { * * @param outputNodeWidth the width of output nodes. */ - @FXThread + @FxThread public void setOutputNodeWidth(final int outputNodeWidth) { final int prev = getOutputNodeWidth(); this.outputNodeWidth = outputNodeWidth; @@ -320,7 +320,7 @@ public void setOutputNodeWidth(final int outputNodeWidth) { * * @param inputNodeWidth the width of input nodes. */ - @FXThread + @FxThread public void setInputNodeWidth(final int inputNodeWidth) { final int prev = getInputNodeWidth(); this.inputNodeWidth = inputNodeWidth; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/CodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/CodePreviewComponent.java index 77c7938..8b9063c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/CodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/CodePreviewComponent.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.renderer.RenderManager; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.code.BaseCodeArea; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public CodePreviewComponent(@NotNull final AssetManager assetManager, @NotNull f createComponents(); } - @FXThread + @FxThread protected abstract void createComponents(); /** @@ -48,7 +48,7 @@ public CodePreviewComponent(@NotNull final AssetManager assetManager, @NotNull f * * @return the render manager. */ - @FXThread + @FxThread protected @NotNull RenderManager getRenderManager() { return renderManager; } @@ -58,7 +58,7 @@ public CodePreviewComponent(@NotNull final AssetManager assetManager, @NotNull f * * @return the asset manager. */ - @FXThread + @FxThread protected @NotNull AssetManager getAssetManager() { return assetManager; } @@ -68,7 +68,7 @@ public CodePreviewComponent(@NotNull final AssetManager assetManager, @NotNull f * * @return the code area. */ - @FXThread + @FxThread protected @NotNull BaseCodeArea getCodeArea() { return notNull(codeArea); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/material/definition/MaterialDefCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/material/definition/MaterialDefCodePreviewComponent.java index 4fe63f0..a4800c5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/material/definition/MaterialDefCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/material/definition/MaterialDefCodePreviewComponent.java @@ -6,7 +6,7 @@ import com.jme3.material.MaterialDef; import com.jme3.material.plugin.export.materialdef.J3mdExporter; import com.jme3.renderer.RenderManager; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.preview.CodePreviewComponent; import com.ss.editor.ui.control.code.BaseCodeArea; import com.ss.editor.ui.control.code.MaterialDefinitionCodeArea; @@ -29,7 +29,7 @@ public MaterialDefCodePreviewComponent(@NotNull final AssetManager assetManager, } @Override - @FXThread + @FxThread protected void createComponents() { codeArea = new MaterialDefinitionCodeArea(); @@ -45,7 +45,7 @@ protected void createComponents() { * * @param materialDef the material definition. */ - @FXThread + @FxThread public void load(@NotNull final MaterialDef materialDef) { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/FragmentShaderCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/FragmentShaderCodePreviewComponent.java index 8ac28a6..8b3b0f5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/FragmentShaderCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/FragmentShaderCodePreviewComponent.java @@ -3,7 +3,7 @@ import com.jme3.asset.AssetManager; import com.jme3.renderer.RenderManager; import com.jme3.shader.Shader; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import org.jetbrains.annotations.NotNull; /** @@ -19,7 +19,7 @@ public FragmentShaderCodePreviewComponent(@NotNull final AssetManager assetManag } @Override - @FXThread + @FxThread protected @NotNull Shader.ShaderType getShaderType() { return Shader.ShaderType.Fragment; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java index 212e86f..3924e27 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java @@ -10,9 +10,9 @@ import com.jme3.shader.Shader; import com.jme3.shader.ShaderGenerator; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.shader.nodes.ui.component.preview.CodePreviewComponent; import com.ss.editor.ui.control.code.BaseCodeArea; @@ -55,7 +55,7 @@ public ShaderCodePreviewComponent(@NotNull final AssetManager assetManager, } @Override - @FXThread + @FxThread protected void createComponents() { final Label languageLabel = new Label(Messages.MODEL_PROPERTY_LANGUAGE + ":"); @@ -85,7 +85,7 @@ protected void createComponents() { * * @return the shader type. */ - @FXThread + @FxThread protected abstract @NotNull Shader.ShaderType getShaderType(); /** @@ -93,7 +93,7 @@ protected void createComponents() { * * @param newValue the new shader language or null. */ - @FXThread + @FxThread private void changeLanguage(@Nullable final String newValue) { final BaseCodeArea codeArea = getCodeArea(); @@ -126,7 +126,7 @@ private void changeLanguage(@Nullable final String newValue) { @FromAnyThread public void load(@NotNull final TechniqueDef techniqueDef) { final ExecutorManager executorManager = ExecutorManager.getInstance(); - executorManager.addJMETask(() -> generateShader(techniqueDef)); + executorManager.addJmeTask(() -> generateShader(techniqueDef)); } /** @@ -134,7 +134,7 @@ public void load(@NotNull final TechniqueDef techniqueDef) { * * @param techniqueDef the technique definition. */ - @JMEThread + @JmeThread private void generateShader(@NotNull final TechniqueDef techniqueDef) { final Renderer renderer = getRenderManager().getRenderer(); @@ -145,13 +145,13 @@ private void generateShader(@NotNull final TechniqueDef techniqueDef) { this.shader = abstractShaderGenerator.generateShader(""); final ExecutorManager executorManager = ExecutorManager.getInstance(); - executorManager.addFXTask(this::loadShader); + executorManager.addFxTask(this::loadShader); } /** * Load languages from the generated shader. */ - @FXThread + @FxThread private void loadShader() { final ComboBox languageBox = getLanguageBox(); @@ -173,7 +173,7 @@ private void loadShader() { * * @return the box with language options. */ - @FXThread + @FxThread private @NotNull ComboBox getLanguageBox() { return notNull(languageBox); } @@ -183,7 +183,7 @@ private void loadShader() { * * @return the current shader. */ - @FXThread + @FxThread protected @NotNull Shader getShader() { return notNull(shader); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/VertexShaderCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/VertexShaderCodePreviewComponent.java index f62ebd1..291a9f3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/VertexShaderCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/VertexShaderCodePreviewComponent.java @@ -3,7 +3,7 @@ import com.jme3.asset.AssetManager; import com.jme3.renderer.RenderManager; import com.jme3.shader.Shader; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import org.jetbrains.annotations.NotNull; /** @@ -19,7 +19,7 @@ public VertexShaderCodePreviewComponent(@NotNull final AssetManager assetManager } @Override - @FXThread + @FxThread protected @NotNull Shader.ShaderType getShaderType() { return Shader.ShaderType.Vertex; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java index 4549657..40cbfbf 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java @@ -5,7 +5,7 @@ import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.*; import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.remove.RemoveRelationShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.line.VariableLine; @@ -127,7 +127,7 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull * * @return the container of nodes parameters. */ - @FXThread + @FxThread protected @NotNull VBox getParametersContainer() { return parametersContainer; } @@ -137,7 +137,7 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull * * @return the tooltip. */ - @FXThread + @FxThread protected @NotNull Optional createTooltip() { return Optional.empty(); } @@ -147,7 +147,7 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull * * @param event the context menu requested event. */ - @FXThread + @FxThread private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { final ShaderNodesContainer container = getContainer(); container.handleContextMenuEvent(event); @@ -161,7 +161,7 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { * @param outputParameter the output parameter. * @return true of we can attach. */ - @FXThread + @FxThread public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { @@ -185,7 +185,7 @@ public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, * @param inputParameter the input parameter. * @param outputParameter the output parameter. */ - @FXThread + @FxThread public void attach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { } @@ -193,7 +193,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, /** * @return the container of this nodes. */ - @FXThread + @FxThread public @NotNull ShaderNodesContainer getContainer() { return container; } @@ -201,7 +201,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, /** * @return the shader object. */ - @FXThread + @FxThread public @NotNull T getObject() { return object; } @@ -214,7 +214,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, * @param input true if the variable is input variable. * @return the parameter or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { return parametersContainer.getChildren().stream() @@ -230,7 +230,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, * * @return the title text of this nodes. */ - @FXThread + @FxThread protected @NotNull String getTitleText() { return "Title"; } @@ -238,7 +238,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, /** * Create UI content of this nodes. */ - @FXThread + @FxThread protected void createContent() { final StackPane header = new StackPane(); @@ -256,7 +256,7 @@ protected void createContent() { /** * Reset layout of this nodes. */ - @FXThread + @FxThread public void resetLayout() { final double layoutX = getLayoutX(); final double layoutY = getLayoutY(); @@ -271,7 +271,7 @@ public void resetLayout() { * * @param container the parameters container. */ - @FXThread + @FxThread protected void fillParameters(@NotNull final VBox container) { } @@ -280,7 +280,7 @@ protected void fillParameters(@NotNull final VBox container) { * * @param event the mouse event. */ - @FXThread + @FxThread private void handleMouseDragged(@NotNull final MouseEvent event) { if (event.getTarget() instanceof SocketElement) { @@ -320,7 +320,7 @@ private void handleMouseDragged(@NotNull final MouseEvent event) { * * @param event the mouse released event. */ - @FXThread + @FxThread private void handleMouseReleased(@NotNull final MouseEvent event) { if (isResizing()) { setResizing(false); @@ -338,7 +338,7 @@ private void handleMouseReleased(@NotNull final MouseEvent event) { * * @param event the mouse moved event. */ - @FXThread + @FxThread private void handleMouseMoved(@NotNull final MouseEvent event) { if (event.getTarget() instanceof SocketElement) { @@ -358,7 +358,7 @@ private void handleMouseMoved(@NotNull final MouseEvent event) { * * @param selected true if this nodes is selected. */ - @FXThread + @FxThread public void setSelected(final boolean selected) { this.selected.setValue(selected); } @@ -368,7 +368,7 @@ public void setSelected(final boolean selected) { * * @param event the mouse pressed event. */ - @FXThread + @FxThread private void handleMousePressed(@NotNull final MouseEvent event) { if (event.getTarget() instanceof SocketElement) { @@ -402,7 +402,7 @@ private void handleMousePressed(@NotNull final MouseEvent event) { * @param event the mouse event. * @return true if we can start to resize. */ - @FXThread + @FxThread protected boolean isInResizableZone(@NotNull final MouseEvent event) { return event.getX() > (getWidth() - RESIZE_MARGIN); } @@ -410,7 +410,7 @@ protected boolean isInResizableZone(@NotNull final MouseEvent event) { /** * @return true if this nodes is dragging now. */ - @FXThread + @FxThread protected boolean isDragging() { return dragging; } @@ -418,7 +418,7 @@ protected boolean isDragging() { /** * @param dragging true if this nodes is dragging now. */ - @FXThread + @FxThread protected void setDragging(final boolean dragging) { this.dragging = dragging; } @@ -426,7 +426,7 @@ protected void setDragging(final boolean dragging) { /** * @return true if this nodes is resizing now. */ - @FXThread + @FxThread protected boolean isResizing() { return resizing; } @@ -434,7 +434,7 @@ protected boolean isResizing() { /** * @param resizing true if this nodes is resizing now. */ - @FXThread + @FxThread protected void setResizing(final boolean resizing) { this.resizing = resizing; } @@ -444,7 +444,7 @@ protected void setResizing(final boolean resizing) { * * @return the action or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return null; } @@ -455,7 +455,7 @@ protected void setResizing(final boolean resizing) { * @param line the line. * @return the action or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeAction getDetachAction(@NotNull final VariableLine line) { return new RemoveRelationShaderNodeAction(getContainer(), line, Vector2f.ZERO); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java index c23828a..90a6f2a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java @@ -11,7 +11,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.*; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -148,7 +148,7 @@ public ShaderNodesContainer(@NotNull final ShaderNodesChangeConsumer changeConsu /** * Notify about changed preview material. */ - @FXThread + @FxThread public void notifyChangedMaterial() { getNodeElements().stream() .filter(MaterialShaderNodeElement.class::isInstance) @@ -161,7 +161,7 @@ public void notifyChangedMaterial() { * * @return all current nodes elements. */ - @FXThread + @FxThread private @NotNull Array> getNodeElements() { return nodeElements; } @@ -169,7 +169,7 @@ public void notifyChangedMaterial() { /** * @return the change consumer. */ - @FXThread + @FxThread public @NotNull ShaderNodesChangeConsumer getChangeConsumer() { return changeConsumer; } @@ -177,7 +177,7 @@ public void notifyChangedMaterial() { /** * Reset all layouts. */ - @FXThread + @FxThread private void invalidateSizes() { final ShaderNodesChangeConsumer consumer = getChangeConsumer(); @@ -209,13 +209,13 @@ private void invalidateSizes() { nodeElement.resize(width, nodeElement.getHeight()); } - EXECUTOR_MANAGER.addFXTask(this::invalidateLayout); + EXECUTOR_MANAGER.addFxTask(this::invalidateLayout); } /** * Update all layouts. */ - @FXThread + @FxThread private void invalidateLayout() { final ShaderNodesChangeConsumer consumer = getChangeConsumer(); @@ -260,7 +260,7 @@ private void invalidateLayout() { /** * Layout nodes. */ - @FXThread + @FxThread private void layoutNodes() { final Array> nodeElements = getNodeElements(); @@ -376,7 +376,7 @@ private void layoutNodes() { /** * Reset all layouts. */ - @FXThread + @FxThread private void resetLayout() { final Array> nodeElements = getNodeElements(); nodeElements.forEach(ShaderNodeElement::resetLayout); @@ -387,7 +387,7 @@ private void resetLayout() { * * @return the temp line to show a process of binding variables. */ - @FXThread + @FxThread private @Nullable TempLine getTempLine() { return tempLine; } @@ -397,7 +397,7 @@ private void resetLayout() { * * @param tempLine the temp line to show a process of binding variables. */ - @FXThread + @FxThread private void setTempLine(@Nullable final TempLine tempLine) { this.tempLine = tempLine; } @@ -407,7 +407,7 @@ private void setTempLine(@Nullable final TempLine tempLine) { * * @param sourceSocket the source socket. */ - @FXThread + @FxThread public void startAttaching(@NotNull final SocketElement sourceSocket) { TempLine tempLine = getTempLine(); @@ -428,7 +428,7 @@ public void startAttaching(@NotNull final SocketElement sourceSocket) { * * @param dragEvent the drag over event. */ - @FXThread + @FxThread private void handleDragOver(@NotNull final DragEvent dragEvent) { if (dragEvent.getGestureSource() instanceof SocketElement) { updateAttaching(dragEvent.getSceneX(), dragEvent.getSceneY()); @@ -441,7 +441,7 @@ private void handleDragOver(@NotNull final DragEvent dragEvent) { * * @param event the mouse event. */ - @FXThread + @FxThread private void handleMouseClicked(@NotNull final MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY && contextMenu.isShowing()) { contextMenu.hide(); @@ -453,7 +453,7 @@ private void handleMouseClicked(@NotNull final MouseEvent event) { * * @param event the context menu event. */ - @FXThread + @FxThread public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { final Object source = event.getSource(); @@ -509,7 +509,7 @@ public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { * @param sceneX the sceneX. * @param sceneY the sceneY. */ - @FXThread + @FxThread public void updateAttaching(final double sceneX, final double sceneY) { final TempLine tempLine = getTempLine(); @@ -522,7 +522,7 @@ public void updateAttaching(final double sceneX, final double sceneY) { /** * Handle finish the process of attaching. */ - @FXThread + @FxThread public void finishAttaching() { final TempLine tempLine = getTempLine(); @@ -537,7 +537,7 @@ public void finishAttaching() { * * @param requester the nodes to select. */ - @FXThread + @FxThread public void requestSelect(@NotNull final ShaderNodeElement requester) { final ObservableList children = root.getChildren(); @@ -554,7 +554,7 @@ public void requestSelect(@NotNull final ShaderNodeElement requester) { * * @return the root component to place all nodes. */ - @FXThread + @FxThread private @NotNull Pane getRoot() { return root; } @@ -564,7 +564,7 @@ public void requestSelect(@NotNull final ShaderNodeElement requester) { * * @param techniqueDef the technique. */ - @FXThread + @FxThread public void show(@NotNull final TechniqueDef techniqueDef) { if (techniqueDef.equals(this.techniqueDef)) return; @@ -619,7 +619,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { nodeElements.forEach(root.getChildren(), (nodeElement, nodes) -> nodes.add(nodeElement)); refreshLines(); - EXECUTOR_MANAGER.addFXTask(this::invalidateSizes); + EXECUTOR_MANAGER.addFxTask(this::invalidateSizes); } /** @@ -628,7 +628,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param leftVariable the left variable. * @return the list of nodes. */ - @FXThread + @FxThread public @NotNull List findWithLeftOutputVar(@NotNull final ShaderNodeVariable leftVariable) { return root.getChildren().stream() .filter(MainShaderNodeElement.class::isInstance) @@ -644,7 +644,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param name the name. * @return the found shader node or null. */ - @FXThread + @FxThread public @Nullable ShaderNode findShaderNodeByName(@NotNull final String name) { if (MaterialShaderNodeElement.NAMESPACE.equals(name) || GlobalShaderNodeElement.NAMESPACE.equals(name) || @@ -666,12 +666,12 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param shaderNode the shader node. * @return the list of used shader nodes. */ - @FXThread + @FxThread public @NotNull List findUsedFrom(@NotNull final ShaderNode shaderNode) { return findUsedFrom(new ArrayList<>(), shaderNode); } - @FXThread + @FxThread private @NotNull List findUsedFrom(@NotNull final List result, @NotNull final ShaderNode shaderNode) { @@ -698,7 +698,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param type the type. * @return the list of nodes. */ - @FXThread + @FxThread public @NotNull List findWithRightInputVar(@NotNull final ShaderNodeVariable rightVariable, @NotNull final Class type) { return root.getChildren().stream() @@ -715,7 +715,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param variable the variable. * @return the nodes element or null. */ - @FXThread + @FxThread private @Nullable ShaderNodeElement findNodeElementByVariable(@NotNull final ShaderNodeVariable variable) { return (ShaderNodeElement) root.getChildren().stream() .filter(ShaderNodeElement.class::isInstance) @@ -730,7 +730,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param object the object. * @return the nodes element or null. */ - @FXThread + @FxThread private @Nullable ShaderNodeElement findNodeElementByObject(@NotNull final Object object) { return (ShaderNodeElement) root.getChildren().stream() .filter(ShaderNodeElement.class::isInstance) @@ -747,7 +747,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param input true if the variable is input variable. * @return the parameter or null. */ - @FXThread + @FxThread private @Nullable ShaderNodeParameter findByVariable(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { return root.getChildren().stream() @@ -764,7 +764,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param matParam the new material parameter. * @param location the location. */ - @FXThread + @FxThread public void addMatParam(@NotNull final MatParam matParam, @NotNull final Vector2f location) { addNodeElement(MaterialShaderNodeElement.toVariable(matParam), location); } @@ -775,7 +775,7 @@ public void addMatParam(@NotNull final MatParam matParam, @NotNull final Vector2 * @param binding the binding. * @param location the location. */ - @FXThread + @FxThread public void addWorldParam(@NotNull final UniformBinding binding, @NotNull final Vector2f location) { addNodeElement(WorldShaderNodeElement.toVariable(binding), location); } @@ -786,7 +786,7 @@ public void addWorldParam(@NotNull final UniformBinding binding, @NotNull final * @param shaderNode the new shader nodes. * @param location the location. */ - @FXThread + @FxThread public void addShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location) { final ShaderNodeDefinition definition = shaderNode.getDefinition(); @@ -809,7 +809,7 @@ public void addShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final V * @param variable the new shader nodes variable. * @param location the location. */ - @FXThread + @FxThread public void addNodeElement(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location) { final ShaderNodeElement nodeElement = createNodeElement(variable); @@ -826,7 +826,7 @@ public void addNodeElement(@NotNull final ShaderNodeVariable variable, @NotNull * @param nodeElement the new nodes element. * @param location the location. */ - @FXThread + @FxThread private void addNodeElement(@NotNull final ShaderNodeElement nodeElement, @NotNull final Vector2f location) { final ObservableList children = root.getChildren(); @@ -838,7 +838,7 @@ private void addNodeElement(@NotNull final ShaderNodeElement nodeElement, @No refreshLines(); EXECUTOR_MANAGER.schedule(() -> { - EXECUTOR_MANAGER.addFXTask(() -> { + EXECUTOR_MANAGER.addFxTask(() -> { nodeElement.setLayoutX(location.getX()); nodeElement.setLayoutY(location.getY()); }); @@ -850,7 +850,7 @@ private void addNodeElement(@NotNull final ShaderNodeElement nodeElement, @No * * @param matParam the material parameter. */ - @FXThread + @FxThread public void removeMatParam(@NotNull final MatParam matParam) { removeNodeElement(MaterialShaderNodeElement.toVariable(matParam)); } @@ -860,7 +860,7 @@ public void removeMatParam(@NotNull final MatParam matParam) { * * @param binding the world parameter. */ - @FXThread + @FxThread public void removeWorldParam(@NotNull final UniformBinding binding) { removeNodeElement(WorldShaderNodeElement.toVariable(binding)); } @@ -870,7 +870,7 @@ public void removeWorldParam(@NotNull final UniformBinding binding) { * * @param shaderNode the shader nodes. */ - @FXThread + @FxThread public void removeShaderNode(@NotNull final ShaderNode shaderNode) { final ShaderNodeElement nodeElement = findNodeElementByObject(shaderNode); if (nodeElement == null) return; @@ -882,7 +882,7 @@ public void removeShaderNode(@NotNull final ShaderNode shaderNode) { * * @param variable the variable. */ - @FXThread + @FxThread public void removeNodeElement(@NotNull final ShaderNodeVariable variable) { final ShaderNodeElement nodeElement = findNodeElementByVariable(variable); @@ -898,7 +898,7 @@ public void removeNodeElement(@NotNull final ShaderNodeVariable variable) { * * @param nodeElement the nodes element. */ - @FXThread + @FxThread private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) { root.getChildren().remove(nodeElement); getNodeElements().slowRemove(nodeElement); @@ -911,7 +911,7 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) * @param variable the variable. * @return the nodes element. */ - @FXThread + @FxThread private @Nullable ShaderNodeElement createNodeElement(@NotNull ShaderNodeVariable variable) { ShaderNodeElement nodeElement = null; @@ -932,7 +932,7 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) * * @return the current technique definition. */ - @FXThread + @FxThread public @NotNull TechniqueDef getTechniqueDef() { return notNull(techniqueDef); } @@ -942,7 +942,7 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) * * @return the current material definition. */ - @FXThread + @FxThread public @NotNull MaterialDef getMaterialDef() { return getChangeConsumer().getMaterialDef(); } @@ -950,7 +950,7 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) /** * Refresh all lines. */ - @FXThread + @FxThread public void refreshLines() { final ObservableList children = root.getChildren(); @@ -985,7 +985,7 @@ public void refreshLines() { * @param mappings the mappings. * @param fromOutputMapping true if it's from output mapping. */ - @FXThread + @FxThread private void buildLines(@NotNull final ObservableList children, @NotNull final List mappings, final boolean fromOutputMapping) { @@ -1013,7 +1013,7 @@ private void buildLines(@NotNull final ObservableList children, @NotNull f /** * Update scale value. */ - @FXThread + @FxThread private void updateScale() { root.setScaleX(scaleValue); root.setScaleY(scaleValue); @@ -1024,7 +1024,7 @@ private void updateScale() { * * @param event the scroll event. */ - @FXThread + @FxThread private void handleScrollEvent(@NotNull final ScrollEvent event) { final double zoomFactor = event.getDeltaY() * ZOOM_INTENSITY; @@ -1062,7 +1062,7 @@ private void handleScrollEvent(@NotNull final ScrollEvent event) { * * @param nodeElement the nodes element. */ - @FXThread + @FxThread public void notifyMoved(@NotNull final ShaderNodeElement nodeElement) { notifyResized(nodeElement); } @@ -1072,7 +1072,7 @@ public void notifyMoved(@NotNull final ShaderNodeElement nodeElement) { * * @param nodeElement the nodes element. */ - @FXThread + @FxThread public void notifyResized(@NotNull final ShaderNodeElement nodeElement) { final Object object = nodeElement.getObject(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java index 8414da0..9c83383 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.action; import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; @@ -53,7 +53,7 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull /** * @return the location. */ - @FXThread + @FxThread public @NotNull Vector2f getLocation() { return location; } @@ -61,7 +61,7 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull /** * @return the shader nodes container. */ - @FXThread + @FxThread public @NotNull ShaderNodesContainer getContainer() { return container; } @@ -69,7 +69,7 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull /** * @return the additional object. */ - @FXThread + @FxThread public @NotNull T getObject() { return object; } @@ -79,13 +79,13 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull * * @return the name of this action. */ - @FXThread + @FxThread protected abstract @NotNull String getName(); /** * Execute this action. */ - @FXThread + @FxThread protected void process() { } @@ -94,7 +94,7 @@ protected void process() { * * @return he icon or null. */ - @FXThread + @FxThread protected @Nullable Image getIcon() { return null; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java index 5e54723..888a54c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java @@ -7,7 +7,7 @@ import com.jme3.math.Vector2f; import com.jme3.scene.VertexBuffer; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.add.AddAttributeOperation; @@ -52,19 +52,19 @@ public AddAttributeShaderNodeAction(@NotNull final ShaderNodesContainer containe } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.VERTEX_ATTRIBUTE; } @Override - @FXThread + @FxThread protected @NotNull String getDialogTitle() { return PluginMessages.ACTION_ADD_VERTEX_ATTRIBUTE_TITLE; } @Override - @FXThread + @FxThread protected void addParameter(@NotNull final VarTable vars) { final ShaderNodesContainer container = getContainer(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java index 6969089..456f44d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java @@ -9,7 +9,7 @@ import com.jme3.math.Vector4f; import com.jme3.shader.VarType; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -65,13 +65,13 @@ public AddMaterialParamShaderNodeAction(@NotNull final ShaderNodesContainer cont } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.MATERIAL_PARAMETER; } @Override - @FXThread + @FxThread protected void process() { super.process(); @@ -87,7 +87,7 @@ protected void process() { * * @return the list of required properties. */ - @FXThread + @FxThread protected @NotNull Array getDefinitions() { final Array varTypes = getVarTypes(); @@ -135,7 +135,7 @@ protected boolean needDefaultValue() { * * @param vars the variables. */ - @FXThread + @FxThread protected void addParam(@NotNull final VarTable vars) { final ShaderNodesContainer container = getContainer(); @@ -191,7 +191,7 @@ protected void addParam(@NotNull final VarTable vars) { * @param vars the variables. * @return true if the values are valid. */ - @FXThread + @FxThread protected boolean validate(@NotNull final VarTable vars) { final String name = vars.getString(PROP_NAME); return getObject().getMaterialParam(name) == null; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialTextureShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialTextureShaderNodeAction.java index 61b1e0f..bc5d2eb 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialTextureShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialTextureShaderNodeAction.java @@ -7,7 +7,7 @@ import com.jme3.shader.VarType; import com.jme3.texture.image.ColorSpace; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.shader.nodes.PluginMessages; @@ -50,13 +50,13 @@ protected boolean needDefaultValue() { } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.MATERIAL_TEXTURE; } @Override - @FXThread + @FxThread protected @NotNull Array getDefinitions() { final Array definitions = super.getDefinitions(); definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_COLOR_SPACE, PROP_COLOR_SPACE, ColorSpace.Linear)); @@ -76,7 +76,7 @@ protected boolean needDefaultValue() { } @Override - @FXThread + @FxThread protected void addParam(@NotNull final VarTable vars) { final ShaderNodesContainer container = getContainer(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java index a7f8d22..41b5441 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java @@ -8,10 +8,9 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.Editor; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -21,6 +20,7 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.add.AddShaderNodeOperation; import com.ss.editor.ui.util.UIUtils; +import com.ss.editor.util.EditorUtil; import com.ss.rlib.util.array.Array; import com.ss.rlib.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; @@ -38,8 +38,7 @@ public class AddNodeShaderNodeAction extends ShaderNodeAction { private static final ResourceManager RESOURCE_MANAGER = ResourceManager.getInstance(); @NotNull - private static final Editor EDITOR = Editor.getInstance(); - public static final String PROP_DEFINITION = "definition"; + private static final String PROP_DEFINITION = "definition"; public AddNodeShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull final TechniqueDef techniqueDef, @NotNull final Vector2f location) { @@ -47,13 +46,13 @@ public AddNodeShaderNodeAction(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.SHADER_NODE; } @Override - @FXThread + @FxThread protected void process() { super.process(); final Array resources = RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_SHADER_NODE); @@ -65,13 +64,13 @@ protected void process() { * * @param resource the selected resource. */ - @FXThread + @FxThread private void addNode(@NotNull final String resource) { final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(resource); key.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final List definitions = assetManager.loadAsset(key); if (definitions.isEmpty()) { @@ -108,7 +107,7 @@ private void addNode(@NotNull final String resource) { * * @param definition the new definition. */ - @FXThread + @FxThread private void addDefinition(final ShaderNodeDefinition definition) { final TechniqueDef techniqueDef = getObject(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddTechniqueDefParameterShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddTechniqueDefParameterShaderNodeAction.java index fb84f77..3fd101a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddTechniqueDefParameterShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddTechniqueDefParameterShaderNodeAction.java @@ -4,7 +4,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; @@ -45,7 +45,7 @@ public AddTechniqueDefParameterShaderNodeAction(@NotNull final ShaderNodesContai } @Override - @FXThread + @FxThread protected void process() { super.process(); @@ -62,7 +62,7 @@ protected void process() { * * @return the dialog title. */ - @FXThread + @FxThread protected @NotNull String getDialogTitle() { throw new RuntimeException("unsupported"); } @@ -73,7 +73,7 @@ protected void process() { * @param vars the variables. * @return true if the values are valid. */ - @FXThread + @FxThread protected boolean validate(@NotNull final VarTable vars) { return available.contains(vars.getString(PROP_NAME)); } @@ -83,6 +83,6 @@ protected boolean validate(@NotNull final VarTable vars) { * * @param vars the variables. */ - @FXThread + @FxThread protected abstract void addParameter(@NotNull final VarTable vars); } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddWorldParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddWorldParamShaderNodeAction.java index 699d041..87fcbc8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddWorldParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddWorldParamShaderNodeAction.java @@ -3,7 +3,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.add.AddWorldParameterOperation; @@ -43,19 +43,19 @@ public AddWorldParamShaderNodeAction(@NotNull final ShaderNodesContainer contain } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.WORLD_PARAMETER; } @Override - @FXThread + @FxThread protected @NotNull String getDialogTitle() { return PluginMessages.ACTION_ADD_WORLD_PARAMETER_TITLE; } @Override - @FXThread + @FxThread protected void addParameter(@NotNull final VarTable vars) { final ShaderNodesContainer container = getContainer(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java index a5aa8de..6e27f36 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java @@ -5,7 +5,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; @@ -29,13 +29,13 @@ public RemoveAttributeShaderNodeAction(@NotNull final ShaderNodesContainer conta } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java index a3a4678..db9716e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java @@ -7,7 +7,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; @@ -31,13 +31,13 @@ public RemoveMaterialParamShaderNodeAction(@NotNull final ShaderNodesContainer c } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java index 7ac2788..420eb29 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java @@ -7,7 +7,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -33,13 +33,13 @@ public RemoveRelationShaderNodeAction(@NotNull final ShaderNodesContainer contai } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java index cec95d7..aed0e3a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; @@ -31,13 +31,13 @@ public RemoveShaderNodeAction(@NotNull final ShaderNodesContainer container, @No } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java index faa8b68..a53a6a5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; @@ -30,13 +30,13 @@ public RemoveWorldParamShaderNodeAction(@NotNull final ShaderNodesContainer cont } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/GlobalShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/GlobalShaderNodeElement.java index a6b5e38..9cc4044 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/GlobalShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/GlobalShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; @@ -24,7 +24,7 @@ public GlobalShaderNodeElement(@NotNull final ShaderNodesContainer container, @N } @Override - @FXThread + @FxThread public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { if (!NAMESPACE.equals(variable.getNameSpace())) return null; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/InputGlobalShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/InputGlobalShaderNodeElement.java index ebf90f1..25a4dee 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/InputGlobalShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/InputGlobalShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; @@ -26,13 +26,13 @@ public InputGlobalShaderNodeElement(@NotNull final ShaderNodesContainer containe } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_GLOBAL_INPUT; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeParameter parameterFor(final @NotNull ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { if (fromOutputMapping) return null; @@ -40,7 +40,7 @@ public InputGlobalShaderNodeElement(@NotNull final ShaderNodesContainer containe } @Override - @FXThread + @FxThread protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/OutputGlobalShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/OutputGlobalShaderNodeElement.java index bc5e699..e1698b8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/OutputGlobalShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/OutputGlobalShaderNodeElement.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; @@ -38,13 +38,13 @@ public OutputGlobalShaderNodeElement(@NotNull final ShaderNodesContainer contain } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_GLOBAL_OUTPUT; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeParameter parameterFor(final @NotNull ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { if (!fromOutputMapping) return null; @@ -52,7 +52,7 @@ public OutputGlobalShaderNodeElement(@NotNull final ShaderNodesContainer contain } @Override - @FXThread + @FxThread protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); @@ -68,7 +68,7 @@ protected void fillParameters(@NotNull final VBox container) { } @Override - @FXThread + @FxThread public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { @@ -89,7 +89,7 @@ public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, } @Override - @FXThread + @FxThread public void attach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { super.attach(inputParameter, outputParameter); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/TempLine.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/TempLine.java index bb38898..c059130 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/TempLine.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/TempLine.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.line; import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_TEMP_LINE; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import javafx.scene.shape.CubicCurve; import javafx.scene.shape.StrokeLineCap; @@ -26,7 +26,7 @@ public TempLine(@NotNull final SocketElement sourceSocket) { /** * Configure the line. */ - @FXThread + @FxThread private void configureLine() { startXProperty().bind(sourceSocket.centerXPropertyProperty()); startYProperty().bind(sourceSocket.centerYPropertyProperty()); @@ -44,7 +44,7 @@ private void configureLine() { * @param x the X coord. * @param y the Y coord. */ - @FXThread + @FxThread public void updateEnd(final double x, final double y) { setEndX(x); setEndY(y); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java index c42179a..184992e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.line; import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_LINE; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; @@ -38,7 +38,7 @@ public VariableLine(@NotNull final ShaderNodeParameter outParameter, * * @param event the menu requested event. */ - @FXThread + @FxThread private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { final ShaderNodeElement nodeElement = inParameter.getNodeElement(); final ShaderNodesContainer container = nodeElement.getContainer(); @@ -51,7 +51,7 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { * * @return the input parameter. */ - @FXThread + @FxThread public @NotNull ShaderNodeParameter getInParameter() { return inParameter; } @@ -61,7 +61,7 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { * * @return the output parameter. */ - @FXThread + @FxThread public @NotNull ShaderNodeParameter getOutParameter() { return outParameter; } @@ -69,7 +69,7 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { /** * Configure the line. */ - @FXThread + @FxThread private void configureLine() { final SocketElement outSocket = outParameter.getSocket(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/AttributeShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/AttributeShaderNodeElement.java index 417b94c..b7ea9f2 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/AttributeShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/AttributeShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -26,19 +26,19 @@ public AttributeShaderNodeElement(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_VERTEX_ATTRIBUTE; } @Override - @FXThread + @FxThread protected @NotNull String getNameSpace() { return NAMESPACE; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return new RemoveAttributeShaderNodeAction(getContainer(), getObject(), new Vector2f((float) getLayoutX(), (float) getLayoutY())); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/FragmentShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/FragmentShaderNodeElement.java index 6de68a2..7696060 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/FragmentShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/FragmentShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.ShaderNode; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.InputGlobalShaderNodeElement; @@ -22,7 +22,7 @@ public FragmentShaderNodeElement(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java index d8bf0bc..a5fe69c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java @@ -4,7 +4,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.*; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -41,18 +41,18 @@ public MainShaderNodeElement(@NotNull final ShaderNodesContainer container, @Not } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return getObject().getDefinition().getName(); } @Override - @FXThread + @FxThread protected @NotNull Optional createTooltip() { return Optional.of(new SndDocumentationTooltip(getObject().getDefinition())); } - @FXThread + @FxThread @Override public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { @@ -65,7 +65,7 @@ public MainShaderNodeElement(@NotNull final ShaderNodesContainer container, @Not return super.parameterFor(variable, fromOutputMapping, input); } - @FXThread + @FxThread @Override protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); @@ -85,7 +85,7 @@ protected void fillParameters(@NotNull final VBox container) { } @Override - @FXThread + @FxThread public void attach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { super.attach(inputParameter, outputParameter); @@ -145,7 +145,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, } @Override - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return new RemoveShaderNodeAction(getContainer(), getObject(), new Vector2f((float) getLayoutX(), (float) getLayoutY())); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java index a1dcb10..25e8a29 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java @@ -9,9 +9,9 @@ import com.jme3.math.Vector4f; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VarType; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; @@ -56,7 +56,7 @@ public MaterialShaderNodeElement(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread protected @NotNull OutputShaderNodeParameter newParameter() { final ShaderNodeVariable variable = getObject(); @@ -88,7 +88,7 @@ public MaterialShaderNodeElement(@NotNull final ShaderNodesContainer container, /** * Notify about changed preview material. */ - @FXThread + @FxThread public void notifyChangedMaterial() { getParametersContainer().getChildren().stream() .filter(EditableMaterialShaderNodeParameter.class::isInstance) @@ -96,7 +96,7 @@ public void notifyChangedMaterial() { .forEach(EditableMaterialShaderNodeParameter::sync); } - @FXThread + @FxThread private @Nullable PropertyControl buildControl(@NotNull final ChangeConsumer consumer, @NotNull final MatParam param) { @@ -138,7 +138,7 @@ public void notifyChangedMaterial() { return null; } - @FXThread + @FxThread private T getCurrentValue(@NotNull final MatParam matParam) { final ShaderNodesChangeConsumer changeConsumer = getContainer().getChangeConsumer(); @@ -159,7 +159,7 @@ private T getCurrentValue(@NotNull final MatParam matParam) { return value; } - @JMEThread + @JmeThread private void applyValue(@NotNull final MatParam matParam, @Nullable T value) { final ShaderNodesChangeConsumer changeConsumer = getContainer().getChangeConsumer(); @@ -177,19 +177,19 @@ private void applyValue(@NotNull final MatParam matParam, @Nullable T value) } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_MATERIAL_PARAMETER; } @Override - @FXThread + @FxThread protected @NotNull String getNameSpace() { return NAMESPACE; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return new RemoveMaterialParamShaderNodeAction(getContainer(), getObject(), new Vector2f((float) getLayoutX(), (float) getLayoutY())); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/OutputVariableShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/OutputVariableShaderNodeElement.java index b92f54f..3c406a9 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/OutputVariableShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/OutputVariableShaderNodeElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.main; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; import com.ss.rlib.ui.util.FXUtils; @@ -21,7 +21,7 @@ public OutputVariableShaderNodeElement(@NotNull final ShaderNodesContainer conta } @Override - @FXThread + @FxThread protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); FXUtils.addToPane(newParameter(), container); @@ -32,7 +32,7 @@ protected void fillParameters(@NotNull final VBox container) { * * @return the output parameter. */ - @FXThread + @FxThread protected @NotNull OutputShaderNodeParameter newParameter() { return new OutputShaderNodeParameter(this, getObject()); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VariableShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VariableShaderNodeElement.java index 7e14527..da78ceb 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VariableShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VariableShaderNodeElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.main; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; @@ -20,7 +20,7 @@ public VariableShaderNodeElement(@NotNull final ShaderNodesContainer container, super(container, variable); } - @FXThread + @FxThread @Override public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { @@ -33,7 +33,7 @@ public VariableShaderNodeElement(@NotNull final ShaderNodesContainer container, * * @return the namespace. */ - @FXThread + @FxThread protected @NotNull String getNameSpace() { return "unknown"; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VertexShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VertexShaderNodeElement.java index 5245083..e21d50e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VertexShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VertexShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.ShaderNode; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.InputGlobalShaderNodeElement; @@ -22,7 +22,7 @@ public VertexShaderNodeElement(@NotNull final ShaderNodesContainer container, @N } @Override - @FXThread + @FxThread public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/WorldShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/WorldShaderNodeElement.java index 144f8ec..3d2e9d3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/WorldShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/WorldShaderNodeElement.java @@ -3,7 +3,7 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -38,19 +38,19 @@ public WorldShaderNodeElement(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_WORLD_PARAMETER; } @Override - @FXThread + @FxThread protected @NotNull String getNameSpace() { return NAMESPACE; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return new RemoveWorldParamShaderNodeAction(getContainer(), getObject(), new Vector2f((float) getLayoutX(), (float) getLayoutY())); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java index 1f9d17c..70f6013 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java @@ -4,7 +4,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.material.logic.*; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,7 +39,7 @@ public ChangeLightModeOperation(@NotNull final String techniqueName, } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); @@ -59,7 +59,7 @@ protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); @@ -83,7 +83,7 @@ protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito * * @param techniqueDef the technique def. */ - @FXThread + @FxThread private void createLogic(@NotNull final TechniqueDef techniqueDef) { switch (techniqueDef.getLightMode()) { case SinglePass: { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ShaderNodeOperation.java index 58fba92..eda55d4 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ShaderNodeOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.operation; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -14,39 +14,39 @@ public class ShaderNodeOperation extends AbstractEditorOperation { @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ShaderNodesChangeConsumer editor) { - EXECUTOR_MANAGER.addJMETask(() -> { + EXECUTOR_MANAGER.addJmeTask(() -> { redoImplInJMEThread(editor); - EXECUTOR_MANAGER.addFXTask(() -> redoImplInFXThread(editor)); + EXECUTOR_MANAGER.addFxTask(() -> redoImplInFXThread(editor)); }); } - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { } - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ShaderNodesChangeConsumer editor) { - EXECUTOR_MANAGER.addJMETask(() -> { + EXECUTOR_MANAGER.addJmeTask(() -> { undoImplInJMEThread(editor); - EXECUTOR_MANAGER.addFXTask(() -> undoImplInFXThread(editor)); + EXECUTOR_MANAGER.addFxTask(() -> undoImplInFXThread(editor)); }); } - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { } - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddAttributeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddAttributeOperation.java index 41520c9..5b51f60 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddAttributeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddAttributeOperation.java @@ -4,8 +4,8 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -45,7 +45,7 @@ public AddAttributeOperation(@NotNull final TechniqueDef techniqueDef, @NotNull } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); @@ -54,14 +54,14 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyAddedAttribute(variable, location); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); @@ -70,7 +70,7 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyRemovedAttribute(variable); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddMaterialParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddMaterialParameterOperation.java index da38a49..97153da 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddMaterialParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddMaterialParameterOperation.java @@ -4,8 +4,8 @@ import com.jme3.material.MatParam; import com.jme3.material.MaterialDef; import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -45,7 +45,7 @@ public AddMaterialParameterOperation(@NotNull final MaterialDef materialDef, @No } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -54,7 +54,7 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyAddedMatParameter(matParam, location); @@ -62,7 +62,7 @@ protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); @@ -71,7 +71,7 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyRemovedMatParameter(matParam); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddShaderNodeOperation.java index fba8bab..7fb3e8b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddShaderNodeOperation.java @@ -5,8 +5,8 @@ import com.jme3.math.Vector2f; import com.jme3.shader.Shader; import com.jme3.shader.ShaderNode; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -54,7 +54,7 @@ public AddShaderNodeOperation(@NotNull final TechniqueDef techniqueDef, @NotNull } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -83,14 +83,14 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyAddedShaderNode(shaderNode, location); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); final List shaderNodes = techniqueDef.getShaderNodes(); @@ -100,7 +100,7 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyRemovedRemovedShaderNode(shaderNode); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddTechniqueOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddTechniqueOperation.java index ac1e237..2e6ddff 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddTechniqueOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddTechniqueOperation.java @@ -2,8 +2,8 @@ import com.jme3.material.MaterialDef; import com.jme3.material.TechniqueDef; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -35,21 +35,21 @@ public AddTechniqueOperation(@NotNull final MaterialDef materialDef, @NotNull fi } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); materialDef.addTechniqueDef(techniqueDef); } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyAddedTechnique(techniqueDef); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); @@ -58,7 +58,7 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyRemovedTechnique(techniqueDef); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddWorldParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddWorldParameterOperation.java index b2829f7..d442015 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddWorldParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddWorldParameterOperation.java @@ -3,8 +3,8 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -42,28 +42,28 @@ public AddWorldParameterOperation(@NotNull final TechniqueDef techniqueDef, @Not } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); techniqueDef.getWorldBindings().add(binding); } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyAddedWorldParameter(binding, location); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); techniqueDef.getWorldBindings().remove(binding); } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyRemovedWorldParameter(binding); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachAttributeToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachAttributeToShaderNodeOperation.java index 15382d6..845687a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachAttributeToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachAttributeToShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,7 +23,7 @@ public AttachAttributeToShaderNodeOperation(@NotNull final ShaderNode shaderNode } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -39,7 +39,7 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachGlobalToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachGlobalToShaderNodeOperation.java index 7681689..e45333e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachGlobalToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachGlobalToShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,7 +23,7 @@ public AttachGlobalToShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -39,7 +39,7 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java index cfcc415..614bdc7 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; @@ -73,20 +73,20 @@ protected AttachShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); notify(editor, oldMapping, newMapping); } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); notify(editor, newMapping, oldMapping); } - @FXThread + @FxThread protected void notify(@NotNull final ShaderNodesChangeConsumer editor, @Nullable final VariableMapping oldMapping, @Nullable final VariableMapping newMapping) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachUniformToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachUniformToShaderNodeOperation.java index 2abbf1c..d2367c1 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachUniformToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachUniformToShaderNodeOperation.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,7 +48,7 @@ public AttachUniformToShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -79,7 +79,7 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToGlobalNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToGlobalNodeOperation.java index 9b6997b..f4762a1 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToGlobalNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToGlobalNodeOperation.java @@ -7,7 +7,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -69,7 +69,7 @@ public AttachVarToGlobalNodeOperation(@NotNull final TechniqueDef techniqueDef, } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -143,7 +143,7 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java index 1ba8ffa..f484b04 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java @@ -8,7 +8,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -68,7 +68,7 @@ public AttachVarToShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -125,7 +125,7 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/DetachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/DetachShaderNodeOperation.java index 22f1863..e69a9ce 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/DetachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/DetachShaderNodeOperation.java @@ -2,9 +2,9 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -58,14 +58,14 @@ protected DetachShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); getMappings().remove(oldMapping); } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyRemovedMapping(shaderNode, oldMapping); @@ -76,20 +76,20 @@ protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito * * @return the mapping list. */ - @JMEThread + @JmeThread protected @NotNull List getMappings() { throw new RuntimeException(); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); getMappings().add(oldMapping); } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyAddedMapping(shaderNode, oldMapping); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/InputDetachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/InputDetachShaderNodeOperation.java index b0a583c..f944876 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/InputDetachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/InputDetachShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -20,7 +20,7 @@ public InputDetachShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread + @JmeThread protected @NotNull List getMappings() { return getShaderNode().getInputMapping(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/OutputDetachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/OutputDetachShaderNodeOperation.java index 91bf3b8..42b500f 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/OutputDetachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/OutputDetachShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -20,7 +20,7 @@ public OutputDetachShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread + @JmeThread protected @NotNull List getMappings() { return getShaderNode().getOutputMapping(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveAttributeVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveAttributeVariableOperation.java index 5d2fb69..cef5fa9 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveAttributeVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveAttributeVariableOperation.java @@ -5,8 +5,8 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -26,7 +26,7 @@ public RemoveAttributeVariableOperation(@NotNull final List shaderNo } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -35,14 +35,14 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyRemovedAttribute(variable); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); @@ -51,7 +51,7 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyAddedAttribute(variable, location); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveMaterialParameterVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveMaterialParameterVariableOperation.java index 19fed38..302bb12 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveMaterialParameterVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveMaterialParameterVariableOperation.java @@ -7,8 +7,8 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -45,7 +45,7 @@ public RemoveMaterialParameterVariableOperation(@NotNull final List } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -54,14 +54,14 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyRemovedMatParameter(matParam); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); @@ -70,7 +70,7 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyAddedMatParameter(matParam, location); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveShaderNodeOperation.java index 2f91534..fe953a1 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveShaderNodeOperation.java @@ -7,8 +7,8 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -41,7 +41,7 @@ public RemoveShaderNodeOperation(@NotNull final List shaderNodes, @N } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -67,14 +67,14 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyRemovedRemovedShaderNode(shaderNode); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); @@ -90,7 +90,7 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyAddedShaderNode(shaderNode, location); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveUniformVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveUniformVariableOperation.java index 622f890..1401a24 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveUniformVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveUniformVariableOperation.java @@ -5,7 +5,7 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,7 +38,7 @@ public RemoveUniformVariableOperation(@NotNull final List shaderNode } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -56,7 +56,7 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveVariableOperation.java index 18da95c..fd145d4 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveVariableOperation.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -33,7 +33,7 @@ public RemoveVariableOperation(@NotNull final List shaderNodes, @Not } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); @@ -47,7 +47,7 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveWorldParameterVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveWorldParameterVariableOperation.java index bf76c06..5f7639e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveWorldParameterVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveWorldParameterVariableOperation.java @@ -5,8 +5,8 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -34,28 +34,28 @@ public RemoveWorldParameterVariableOperation(@NotNull final List sha } @Override - @JMEThread + @JmeThread protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJMEThread(editor); techniqueDef.getWorldBindings().remove(binding); } @Override - @FXThread + @FxThread protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInFXThread(editor); editor.notifyRemovedWorldParameter(binding); } @Override - @JMEThread + @JmeThread protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJMEThread(editor); techniqueDef.getWorldBindings().add(binding); } @Override - @FXThread + @FxThread protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInFXThread(editor); editor.notifyAddedWorldParameter(binding, location); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java index 6dfd6be..d8e574e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java @@ -3,7 +3,7 @@ import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_MATERIAL_OUTPUT_PARAMETER; import com.jme3.material.MatParam; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MaterialShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.OutputSocketElement; @@ -41,19 +41,19 @@ public EditableMaterialShaderNodeParameter(@NotNull final MaterialShaderNodeElem /** * Sync the current value of this parameter. */ - @FXThread + @FxThread public void sync() { propertyControl.sync(); } @Override - @FXThread + @FxThread protected @NotNull SocketElement createSocket() { return new OutputSocketElement(this); } @Override - @FXThread + @FxThread protected void createContent() { } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index 88e3623..a04b49c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -2,7 +2,7 @@ import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_INPUT_PARAMETER; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.InputSocketElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; @@ -23,13 +23,13 @@ public InputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, } @Override - @FXThread + @FxThread protected @NotNull SocketElement createSocket() { return new InputSocketElement(this); } @Override - @FXThread + @FxThread protected void createContent() { super.createContent(); FXUtils.addToPane(getSocket(), this); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java index 206abb3..d5ef326 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java @@ -2,7 +2,7 @@ import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_OUTPUT_PARAMETER; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.OutputSocketElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; @@ -23,13 +23,13 @@ public OutputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement } @Override - @FXThread + @FxThread protected @NotNull SocketElement createSocket() { return new OutputSocketElement(this); } @Override - @FXThread + @FxThread protected void createContent() { super.createContent(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java index bc8a62b..6c531dd 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java @@ -3,7 +3,7 @@ import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_PARAMETER; import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_PARAMETER_SOCKET; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import com.ss.rlib.ui.util.FXUtils; @@ -65,7 +65,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, * * @return the shader nodes element. */ - @FXThread + @FxThread public @NotNull ShaderNodeElement getNodeElement() { return nodeElement; } @@ -75,7 +75,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, * * @return the socket element. */ - @FXThread + @FxThread protected @NotNull SocketElement createSocket() { return new SocketElement(this); } @@ -83,7 +83,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * @return the type label. */ - @FXThread + @FxThread protected @NotNull Label getTypeLabel() { return typeLabel; } @@ -91,7 +91,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * @return the name label. */ - @FXThread + @FxThread protected @NotNull Label getNameLabel() { return nameLabel; } @@ -99,7 +99,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * @return the socket. */ - @FXThread + @FxThread public @NotNull SocketElement getSocket() { return socket; } @@ -107,7 +107,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * @return the variable. */ - @FXThread + @FxThread public @NotNull ShaderNodeVariable getVariable() { return variable; } @@ -115,7 +115,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * Create content of this parameter. */ - @FXThread + @FxThread protected void createContent() { final ShaderNodeVariable variable = getVariable(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java index c1f11b4..4f46dd0 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket; import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_PARAMETER_INPUT_SOCKET; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.InputShaderNodeParameter; @@ -88,7 +88,7 @@ public InputSocketElement(@NotNull final ShaderNodeParameter parameter) { * * @param dragEvent the drag event. */ - @FXThread + @FxThread private void handleDragExited(@NotNull final DragEvent dragEvent) { droppable.setValue(false); } @@ -98,7 +98,7 @@ private void handleDragExited(@NotNull final DragEvent dragEvent) { * * @param dragEvent the drag event. */ - @FXThread + @FxThread private void handleDragDropped(@NotNull final DragEvent dragEvent) { droppable.setValue(false); @@ -125,7 +125,7 @@ private void handleDragDropped(@NotNull final DragEvent dragEvent) { * * @param dragEvent the drag event. */ - @FXThread + @FxThread private void handleDragOver(@NotNull final DragEvent dragEvent) { final InputShaderNodeParameter parameter = (InputShaderNodeParameter) getParameter(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java index 37eacef..98339d7 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket; import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_PARAMETER_OUTPUT_SOCKET; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; @@ -61,7 +61,7 @@ public OutputSocketElement(@NotNull final ShaderNodeParameter parameter) { * * @param mouseEvent the mouse event. */ - @FXThread + @FxThread private void handleMouseDragged(final MouseEvent mouseEvent) { final ShaderNodeParameter parameter = getParameter(); final ShaderNodeElement nodeElement = parameter.getNodeElement(); @@ -76,7 +76,7 @@ private void handleMouseDragged(final MouseEvent mouseEvent) { * * @param dragEvent the drag event. */ - @FXThread + @FxThread private void handleStopDrag(@NotNull final DragEvent dragEvent) { setCursor(Cursor.DEFAULT); @@ -94,7 +94,7 @@ private void handleStopDrag(@NotNull final DragEvent dragEvent) { * * @param mouseEvent the mouse event. */ - @FXThread + @FxThread private void handleStartDrag(@NotNull final MouseEvent mouseEvent) { setCursor(Cursor.MOVE); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java index d9409e5..55e0aac 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; import javafx.beans.property.DoubleProperty; @@ -53,7 +53,7 @@ public SocketElement(@NotNull final ShaderNodeParameter parameter) { * * @return the nodes parameter element. */ - @FXThread + @FxThread protected @NotNull ShaderNodeParameter getParameter() { return parameter; } @@ -65,7 +65,7 @@ public SocketElement(@NotNull final ShaderNodeParameter parameter) { * @param oldValue the old value. * @param newValue the new value. */ - @FXThread + @FxThread private void updateCenterCoords(@Nullable final ObservableValue observable, @Nullable final Number oldValue, @Nullable final Number newValue) { @@ -87,7 +87,7 @@ private void updateCenterCoords(@Nullable final ObservableValue { - @NotNull - private static final Editor EDITOR = Editor.getInstance(); - @NotNull private final ShaderNodeDefinition definition; @@ -36,13 +33,13 @@ public SndDocumentationTooltip(@NotNull final ShaderNodeDefinition definition) { } @Override - @FXThread + @FxThread protected @NotNull BorderPane createRoot() { return new BorderPane(); } @Override - @FXThread + @FxThread protected void createContent(@NotNull final BorderPane root) { super.createContent(root); this.documentation = new SndDocumentationArea(); @@ -56,7 +53,7 @@ protected void createContent(@NotNull final BorderPane root) { * * @return the definition. */ - @FXThread + @FxThread private @NotNull ShaderNodeDefinition getDefinition() { return definition; } @@ -66,20 +63,20 @@ protected void createContent(@NotNull final BorderPane root) { * * @return the area to show documentation. */ - @FXThread + @FxThread private @NotNull SndDocumentationArea getDocumentation() { return notNull(documentation); } @Override - @FXThread + @FxThread protected void show() { final ShaderNodeDefinition definition = getDefinition(); final ShaderNodeDefinitionKey assetKey = new ShaderNodeDefinitionKey(definition.getPath()); assetKey.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); String documentation = assetManager.loadAsset(assetKey).stream() .filter(def -> def.getName().equals(definition.getName())) .map(ShaderNodeDefinition::getDocumentation) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java index 072f0c9..063828b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java @@ -7,7 +7,7 @@ import com.jme3.shader.Shader.ShaderType; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -45,19 +45,19 @@ public AddSndAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.ACTION_ADD_SHADER_NODE_DEFINITION; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.ADD_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); @@ -76,7 +76,7 @@ protected void process() { * * @param vars the vars of the definition. */ - @FXThread + @FxThread private boolean validate(@NotNull final VarTable vars) { final String name = vars.getString(PROP_NAME); @@ -93,7 +93,7 @@ private boolean validate(@NotNull final VarTable vars) { * * @param vars the vars of the definition. */ - @FXThread + @FxThread private void addDefinition(@NotNull final VarTable vars) { final String definitionName = vars.getString(PROP_NAME); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java index 70f9a2c..d468d6a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -22,13 +22,13 @@ public AddSndInputParameterAction(@NotNull final NodeTree nodeTree, } @Override - @FXThread + @FxThread protected @NotNull List getCurrentParameters(@NotNull final ShaderNodeDefinition definition) { return definition.getInputs(); } @Override - @FXThread + @FxThread protected @NotNull List getOppositeParameters(@NotNull final ShaderNodeDefinition definition) { return definition.getOutputs(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java index 2495344..adc1a7f 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -22,13 +22,13 @@ public AddSndOutputParameterAction(@NotNull final NodeTree nodeTree, } @Override - @FXThread + @FxThread protected @NotNull List getCurrentParameters(@NotNull final ShaderNodeDefinition definition) { return definition.getOutputs(); } @Override - @FXThread + @FxThread protected @NotNull List getOppositeParameters(@NotNull final ShaderNodeDefinition definition) { return definition.getInputs(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java index c5c5995..d4e118d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -17,7 +17,7 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.editor.util.GLSLType; +import com.ss.editor.util.GlslType; import com.ss.rlib.util.StringUtils; import com.ss.rlib.util.VarTable; import com.ss.rlib.util.array.Array; @@ -47,13 +47,13 @@ public AddSndParameterAction(@NotNull final NodeTree nodeTree, @NotNull final } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.ACTION_ADD_SND_PARAMETER; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.ADD_16; } @@ -64,7 +64,7 @@ public AddSndParameterAction(@NotNull final NodeTree nodeTree, @NotNull final * @param definition the definition. * @return the list of current parameters. */ - @FXThread + @FxThread protected abstract @NotNull List getCurrentParameters( @NotNull final ShaderNodeDefinition definition); @@ -74,18 +74,18 @@ public AddSndParameterAction(@NotNull final NodeTree nodeTree, @NotNull final * @param definition the definition. * @return the list of opposite parameters. */ - @FXThread + @FxThread protected abstract @NotNull List getOppositeParameters( @NotNull final ShaderNodeDefinition definition); @Override - @FXThread + @FxThread protected void process() { super.process(); final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(STRING, Messages.MODEL_PROPERTY_NAME, PROP_NAME, "newVar")); - definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_TYPE, PROP_TYPE, GLSLType.FLOAT)); + definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_TYPE, PROP_TYPE, GlslType.FLOAT)); final GenericFactoryDialog dialog = new GenericFactoryDialog(definitions, this::addParameter, this::validate); dialog.setTitle(getName()); @@ -97,7 +97,7 @@ protected void process() { * * @param vars the vars of the new parameter. */ - @FXThread + @FxThread private boolean validate(@NotNull final VarTable vars) { final TreeNode node = getNode(); @@ -112,7 +112,7 @@ private boolean validate(@NotNull final VarTable vars) { return false; } - final GLSLType glslType = vars.getEnum(PROP_TYPE, GLSLType.class); + final GlslType glslType = vars.getEnum(PROP_TYPE, GlslType.class); final String rawType = glslType.getRawType(); final List oppositeParameters = getOppositeParameters(definition); @@ -133,15 +133,14 @@ private boolean validate(@NotNull final VarTable vars) { * * @param vars the vars of the parameter. */ - @FXThread + @FxThread private void addParameter(@NotNull final VarTable vars) { final TreeNode node = getNode(); final SndParameters parameters = (SndParameters) node.getElement(); final String name = vars.getString(PROP_NAME); - final GLSLType glslType = vars.getEnum(PROP_TYPE, GLSLType.class); - + final GlslType glslType = vars.getEnum(PROP_TYPE, GlslType.class); final ShaderNodeVariable variable = new ShaderNodeVariable(glslType.getRawType(), name); final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer()); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java index b5f2ba0..bce7498 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java @@ -8,7 +8,7 @@ import com.jme3.renderer.Caps; import com.jme3.shader.Shader; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -47,19 +47,19 @@ public AddSndShaderSourceAction(@NotNull final NodeTree nodeTree, @NotNull fi } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.ACTION_ADD_SHADER_NODE_SOURCE; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.ADD_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); @@ -84,7 +84,7 @@ protected void process() { * * @param vars the vars of the definition. */ - @FXThread + @FxThread private boolean validate(@NotNull final VarTable vars) { if (!vars.has(PROP_SHADER_RESOURCE)) { @@ -106,7 +106,7 @@ private boolean validate(@NotNull final VarTable vars) { * * @param vars the vars of the source. */ - @FXThread + @FxThread private void addShaderSource(@NotNull final VarTable vars) { final String language = vars.getString(PROP_LANGUAGE); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java index ba40165..a12a967 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; import com.ss.editor.shader.nodes.ui.control.tree.operation.DeleteSndOperation; @@ -27,19 +27,19 @@ public DeleteSndAction(@NotNull final NodeTree nodeTree, @NotNull final TreeN } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.REMOVE_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java index 8b76401..52bccd4 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java @@ -2,7 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSources; @@ -27,19 +27,19 @@ public DeleteSndShaderSourceAction(@NotNull final NodeTree nodeTree, @NotNull } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.REMOVE_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java index e023408..5fba766 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; import com.ss.editor.shader.nodes.ui.control.tree.operation.DeleteSndParameterOperation; @@ -27,19 +27,19 @@ public DeleteSndarameterAction(@NotNull final NodeTree nodeTree, @NotNull fin } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.REMOVE_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java index 7dfddf8..80c541c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java @@ -2,7 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndDocumentation; @@ -28,19 +28,19 @@ public EditSndDocumentationAction(@NotNull final NodeTree nodeTree, @NotNull } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.ACTION_ADD_EDIT_DOCUMENTATION; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.EDIT_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java index 8efcb79..0a3b51a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ClassUtils.unsafeCast; import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.model.PreviewMaterialSettings; import com.ss.editor.shader.nodes.model.shader.node.definition.*; @@ -29,7 +29,7 @@ public class ShaderNodesTreeNodeFactory implements TreeNodeFactory { } @Override - @FXThread + @FxThread public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof PreviewMaterialSettings) { @@ -56,7 +56,7 @@ public class ShaderNodesTreeNodeFactory implements TreeNodeFactory { } @Override - @FXThread + @FxThread public int getOrder() { return 5; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndDocumentationTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndDocumentationTreeNode.java index 49f35a9..82293f8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndDocumentationTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndDocumentationTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndDocumentation; @@ -26,14 +26,14 @@ public SndDocumentationTreeNode(@NotNull final SndDocumentation element, final l } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new EditSndDocumentationAction(nodeTree, this)); } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.DOCUMENT_16; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndListTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndListTreeNode.java index 89123a2..0602b4b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndListTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndListTreeNode.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; @@ -31,14 +31,14 @@ public SndListTreeNode(@NotNull final SndList element, final long objectId) { } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new AddSndAction(nodeTree, this)); } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.LIST_16; } @@ -50,7 +50,7 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final } @Override - @FXThread + @FxThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { final SndList definitionList = getElement(); final List definitions = definitionList.getDefinitions(); @@ -58,7 +58,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override - @FXThread + @FxThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final SndList definitionList = getElement(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java index 14436be..8336e37 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java @@ -2,7 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -30,13 +30,13 @@ public SndParameterTreeNode(@NotNull final ShaderNodeVariable element, final lon } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new DeleteSndarameterAction(nodeTree, this)); } - @FXThread + @FxThread @Override public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { if (StringUtils.equals(getName(), newName)) return; @@ -52,7 +52,7 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.VARIABLE_16; } @@ -64,7 +64,7 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin } @Override - @FXThread + @FxThread public boolean canEditName() { return true; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParametersTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParametersTreeNode.java index 6ca0a6d..8b4af72 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParametersTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParametersTreeNode.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -41,14 +41,14 @@ public SndParametersTreeNode(@NotNull final SndParameters element, final long ob } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return getElement() instanceof SndInputParameters ? PluginIcons.ARROW_RIGHT_16 : PluginIcons.ARROW_LEFT_16; } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); @@ -61,7 +61,7 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final } @Override - @FXThread + @FxThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { final SndParameters element = getElement(); final List parameters = element.getParameters(); @@ -69,7 +69,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override - @FXThread + @FxThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final SndParameters element = getElement(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourceTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourceTreeNode.java index 42f62df..ce9ee79 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourceTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourceTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; import com.ss.editor.shader.nodes.ui.control.tree.action.DeleteSndShaderSourceAction; @@ -25,14 +25,14 @@ public SndShaderSourceTreeNode(@NotNull final SndShaderSource element, final lon } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new DeleteSndShaderSourceAction(nodeTree, this)); } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.CODE_16; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourcesTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourcesTreeNode.java index a4d7cf5..4a37d96 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourcesTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourcesTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; @@ -37,20 +37,20 @@ public SndShaderSourcesTreeNode(@NotNull final SndShaderSources element, final l } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new AddSndShaderSourceAction(nodeTree, this)); } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.CODE_16; } @Override - @FXThread + @FxThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { final SndShaderSources element = getElement(); final Map sourceMap = element.getShadeSourceMap(); @@ -58,7 +58,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override - @FXThread + @FxThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final SndShaderSources element = getElement(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndTreeNode.java index 337345b..af1571d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndTreeNode.java @@ -2,7 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.*; @@ -33,7 +33,7 @@ public SndTreeNode(@NotNull final ShaderNodeDefinition element, final long objec } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { final ShaderNodeDefinition element = getElement(); @@ -53,7 +53,7 @@ public SndTreeNode(@NotNull final ShaderNodeDefinition element, final long objec } @Override - @FXThread + @FxThread public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { if (StringUtils.equals(getName(), newName)) return; @@ -68,19 +68,19 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin } @Override - @FXThread + @FxThread public boolean canEditName() { return true; } @Override - @FXThread + @FxThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return true; } @Override - @FXThread + @FxThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final ShaderNodeDefinition definition = getElement(); @@ -95,7 +95,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new DeleteSndAction(nodeTree, this)); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java index 117b385..0fa8715 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; @@ -33,14 +33,14 @@ public AddSndOperation(@NotNull final SndList definitionList, } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().add(definition); editor.notifyFXAddedChild(definitionList, definition, -1, true); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().remove(definition); editor.notifyFXRemovedChild(definitionList, definition); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java index f944b28..28f8243 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -35,7 +35,7 @@ public AddSndParameterOperation(@NotNull final SndParameters parameters, } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.add(variable); @@ -43,7 +43,7 @@ protected void redoImpl(@NotNull final ChangeConsumer editor) { } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.remove(variable); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java index 910c824..6b24701 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; @@ -33,14 +33,14 @@ public AddSndShaderSourceOperation(@NotNull final SndShaderSources shaderSources } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { shaderSources.add(shaderSource); editor.notifyFXAddedChild(shaderSources, shaderSource, -1, true); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { shaderSources.remove(shaderSource); editor.notifyFXRemovedChild(shaderSources, shaderSources); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java index 8ab0bef..36dc258 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import org.jetbrains.annotations.NotNull; @@ -34,14 +34,14 @@ public ChangeSndDocumentationOperation(@NotNull final ShaderNodeDefinition defin } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definition.setDocumentation(newDocumentation); editor.notifyFXChangeProperty(definition, "documentation"); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definition.setDocumentation(oldDocumentation); editor.notifyFXChangeProperty(definition, "documentation"); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java index e40ad92..b0a1907 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; @@ -40,7 +40,7 @@ public DeleteSndOperation(@NotNull final SndList definitionList, } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { final List definitions = definitionList.getDefinitions(); index = definitions.indexOf(definition); @@ -49,7 +49,7 @@ protected void redoImpl(@NotNull final ChangeConsumer editor) { } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().add(index, definition); editor.notifyFXAddedChild(definitionList, definition, index, false); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java index beea36d..fee3fb3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -40,7 +40,7 @@ public DeleteSndParameterOperation(@NotNull final SndParameters parameters, } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); index = parameterList.indexOf(variable); @@ -49,7 +49,7 @@ protected void redoImpl(@NotNull final ChangeConsumer editor) { } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.add(index, variable); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java index d45d0c8..cbb69f0 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; @@ -38,7 +38,7 @@ public DeleteSndShaderSourceOperation(@NotNull final SndShaderSources shaderSour } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { index = shaderSources.indexOf(shaderSource); shaderSources.remove(shaderSource); @@ -46,7 +46,7 @@ protected void redoImpl(@NotNull final ChangeConsumer editor) { } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { shaderSources.add(index, shaderSource); editor.notifyFXAddedChild(shaderSources, shaderSource, index, false); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java index 7d5d135..b5d5663 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; @@ -49,14 +49,14 @@ public RenameSndOperation(@NotNull final String oldName, @NotNull final String n } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definition.setName(newName); editor.notifyFXChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definition.setName(oldName); editor.notifyFXChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java index acf6225..72a6ad5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -49,14 +49,14 @@ public RenameSndParameterOperation(@NotNull final String oldName, @NotNull final } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { variable.setName(newName); editor.notifyFXChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { variable.setName(oldName); editor.notifyFXChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java index 5ba86ff..5fb2736 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java @@ -4,14 +4,14 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.extension.property.SimpleProperty; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.builder.impl.EditableObjectPropertyBuilder; -import com.ss.editor.util.GLSLType; +import com.ss.editor.util.GlslType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,9 +27,9 @@ public class ShaderNodesPropertyBuilder extends EditableObjectPropertyBuilder { @NotNull - private static final EnumSet NOT_AVAILABLE_DEFAULT_VALUE = EnumSet.of( - GLSLType.SAMPLER_2D, - GLSLType.SAMPLER_CUBE + private static final EnumSet NOT_AVAILABLE_DEFAULT_VALUE = EnumSet.of( + GlslType.SAMPLER_2D, + GlslType.SAMPLER_CUBE ); /** @@ -53,7 +53,7 @@ protected ShaderNodesPropertyBuilder() { } @Override - @FXThread + @FxThread protected @Nullable List> getProperties(@NotNull final Object object) { if (!(object instanceof ShaderNodeDefinition || object instanceof ShaderNodeVariable)) { @@ -72,10 +72,10 @@ protected ShaderNodesPropertyBuilder() { } else if (object instanceof ShaderNodeVariable) { final ShaderNodeVariable variable = (ShaderNodeVariable) object; - final GLSLType glslType = GLSLType.ofRawType(variable.getType()); + final GlslType glslType = GlslType.ofRawType(variable.getType()); result.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_TYPE, variable, - var -> GLSLType.ofRawType(var.getType()), + var -> GlslType.ofRawType(var.getType()), (var, type) -> var.setType(type.getRawType()))); if (!NOT_AVAILABLE_DEFAULT_VALUE.contains(glslType)) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java index 9e40865..06d3699 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java @@ -4,7 +4,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.PluginMessages; @@ -61,13 +61,13 @@ public EditSndDocumentationDialog(@NotNull final ChangeConsumer consumer, * * @return the editor area. */ - @FXThread + @FxThread private @NotNull SndDocumentationArea getEditorArea() { return notNull(editorArea); } @Override - @FXThread + @FxThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -92,7 +92,7 @@ protected void createContent(@NotNull final VBox root) { } @Override - @FXThread + @FxThread protected void processOk() { super.processOk(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java index 9148d14..c1d1d97 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java @@ -3,9 +3,8 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.ShaderNodeDefinitionKey; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.Editor; import com.ss.editor.FileExtensions; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.SndDocumentationArea; import com.ss.editor.ui.preview.impl.AbstractFilePreview; import com.ss.editor.util.EditorUtil; @@ -24,11 +23,8 @@ */ public class SndFilePreview extends AbstractFilePreview { - @NotNull - private static final Editor EDITOR = Editor.getInstance(); - @Override - @FXThread + @FxThread protected @NotNull SndDocumentationArea createGraphicsNode() { final SndDocumentationArea documentationArea = new SndDocumentationArea(); documentationArea.setEditable(false); @@ -36,7 +32,7 @@ public class SndFilePreview extends AbstractFilePreview { } @Override - @FXThread + @FxThread protected void initialize(@NotNull final SndDocumentationArea node, @NotNull final StackPane pane) { super.initialize(node, pane); node.prefWidthProperty().bind(pane.widthProperty()); @@ -44,7 +40,7 @@ protected void initialize(@NotNull final SndDocumentationArea node, @NotNull fin } @Override - @FXThread + @FxThread public void show(@NotNull final Path file) { super.show(file); @@ -52,13 +48,13 @@ public void show(@NotNull final Path file) { final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(assetPath); key.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final List definitionList = assetManager.loadAsset(key); show(definitionList); } - @FXThread + @FxThread private void show(@NotNull final List definitionList) { final SndDocumentationArea documentationArea = getGraphicsNode(); @@ -97,27 +93,27 @@ private void show(@NotNull final List definitionList) { } @Override - @FXThread + @FxThread public void show(@NotNull final String resource) { super.show(resource); final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(resource); key.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final List definitionList = assetManager.loadAsset(key); show(definitionList); } @Override - @FXThread + @FxThread public boolean isSupport(@NotNull final Path file) { final String extension = FileUtils.getExtension(file); return FileExtensions.JME_SHADER_NODE.equals(extension); } - @FXThread + @FxThread @Override public boolean isSupport(@NotNull final String resource) { final String extension = FileUtils.getExtension(resource); @@ -125,7 +121,7 @@ public boolean isSupport(@NotNull final String resource) { } @Override - @FXThread + @FxThread public int getOrder() { return 10; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java index 7cc784c..05ccdce 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.preview; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.preview.FilePreview; import com.ss.editor.ui.preview.FilePreviewFactory; import com.ss.rlib.util.array.Array; @@ -21,7 +21,7 @@ public class SndFilePreviewFactory implements FilePreviewFactory { } @Override - @FXThread + @FxThread public void createFilePreviews(@NotNull final Array result) { result.add(new SndFilePreview()); } diff --git a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java index 0ff83c8..74d0030 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java @@ -14,7 +14,7 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.OutputGlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.InputShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; -import com.ss.editor.util.GLSLType; +import com.ss.editor.util.GlslType; import com.ss.rlib.util.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -447,7 +447,7 @@ public static boolean isAccessibleType(@NotNull final String inType, @NotNull fi @FromAnyThread public static boolean isRequired(@NotNull final ShaderNodeVariable variable) { - final GLSLType glslType = GLSLType.ofRawType(variable.getType()); + final GlslType glslType = GlslType.ofRawType(variable.getType()); switch (glslType) { case SAMPLER_2D: From b20ad453dcb74e5cfec092ff32db8dde05b4917f Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Fri, 19 Jan 2018 08:28:38 +0300 Subject: [PATCH 08/25] updated compatibility. --- build.gradle | 2 +- pbrMainVertex.vert | 76 +++++++++++++++++++ .../shader/nodes/ShaderNodesEditorPlugin.java | 22 +++--- .../ShaderNodeDefinitionsFileCreator.java | 4 +- .../ShaderNodeDefinitionFileEditor.java | 16 ++-- .../editor/ShaderNodesEditor3DState.java | 7 +- .../editor/ShaderNodesFileEditor.java | 46 +++++------ .../shader/ShaderCodePreviewComponent.java | 6 +- .../action/add/AddNodeShaderNodeAction.java | 4 +- .../operation/ChangeLightModeOperation.java | 4 +- .../factory/ShaderNodesTreeNodeFactory.java | 4 +- .../node/PreviewMaterialSettingsTreeNode.java | 2 +- .../tree/operation/AddSndOperation.java | 4 +- .../operation/AddSndParameterOperation.java | 4 +- .../AddSndShaderSourceOperation.java | 4 +- .../ChangeSndDocumentationOperation.java | 4 +- .../tree/operation/DeleteSndOperation.java | 4 +- .../DeleteSndParameterOperation.java | 4 +- .../DeleteSndShaderSourceOperation.java | 4 +- .../tree/operation/RenameSndOperation.java | 4 +- .../RenameSndParameterOperation.java | 4 +- .../ui/dialog/EditSndDocumentationDialog.java | 2 +- 22 files changed, 154 insertions(+), 77 deletions(-) create mode 100644 pbrMainVertex.vert diff --git a/build.gradle b/build.gradle index 0b57279..e783736 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'idea' apply plugin: 'org.junit.platform.gradle.plugin' group = 'com.spaceshift' -version = '1.1.0' +version = '1.1.1' ext.artifactId = 'shader-nodes' diff --git a/pbrMainVertex.vert b/pbrMainVertex.vert new file mode 100644 index 0000000..93248ee --- /dev/null +++ b/pbrMainVertex.vert @@ -0,0 +1,76 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" +#import "Common/ShaderLib/Instancing.glsllib" +#import "Common/ShaderLib/Skinning.glsllib" + +uniform vec4 m_BaseColor; + +uniform vec4 g_AmbientLightColor; +varying vec2 texCoord; + +#ifdef SEPARATE_TEXCOORD + varying vec2 texCoord2; + attribute vec2 inTexCoord2; +#endif + +varying vec4 Color; + +attribute vec3 inPosition; +attribute vec2 inTexCoord; +attribute vec3 inNormal; + +#ifdef VERTEX_COLOR + attribute vec4 inColor; +#endif + +varying vec3 wNormal; +varying vec3 wPosition; +#if defined(NORMALMAP) || defined(PARALLAXMAP) + attribute vec4 inTangent; + varying vec4 wTangent; +#endif + +void main() { + vec4 modelSpacePos = vec4(inPosition, 1.0); + vec3 modelSpaceNorm = inNormal; + + #if ( defined(NORMALMAP) || defined(PARALLAXMAP)) && !defined(VERTEX_LIGHTING) + vec3 modelSpaceTan = inTangent.xyz; + #endif + + #ifdef NUM_BONES + #if defined(NORMALMAP) && !defined(VERTEX_LIGHTING) + Skinning_Compute(modelSpacePos, modelSpaceNorm, modelSpaceTan); + #else + Skinning_Compute(modelSpacePos, modelSpaceNorm); + #endif + #endif + + #ifdef NUM_BONES + #if defined(NORMALMAP) && !defined(VERTEX_LIGHTING) + Skinning_Compute(modelSpacePos, modelSpaceNorm, modelSpaceTan); + #elif defined(NORMALMAP) + Skinning_Compute(modelSpacePos, modelSpaceNorm); + #else + Skinning_Compute(modelSpacePos); + #endif + #endif + + gl_Position = TransformWorldViewProjection(modelSpacePos); + texCoord = inTexCoord; + #ifdef SEPARATE_TEXCOORD + texCoord2 = inTexCoord2; + #endif + + wPosition = TransformWorld(modelSpacePos).xyz; + wNormal = TransformWorldNormal(modelSpaceNorm); + + #if defined(NORMALMAP) || defined(PARALLAXMAP) + wTangent = vec4(TransformWorldNormal(modelSpaceTan),inTangent.w); + #endif + + Color = m_BaseColor; + + #ifdef VERTEX_COLOR + Color *= inColor; + #endif +} \ No newline at end of file diff --git a/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java b/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java index 6520b4c..85c24db 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java +++ b/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java @@ -19,8 +19,8 @@ import com.ss.editor.ui.component.creator.FileCreatorRegistry; import com.ss.editor.ui.component.editor.EditorRegistry; import com.ss.editor.ui.control.property.builder.PropertyBuilderRegistry; -import com.ss.editor.ui.control.tree.node.TreeNodeFactoryRegistry; -import com.ss.editor.ui.css.CSSRegistry; +import com.ss.editor.ui.control.tree.node.factory.TreeNodeFactoryRegistry; +import com.ss.editor.ui.css.CssRegistry; import com.ss.editor.ui.preview.FilePreviewFactoryRegistry; import com.ss.editor.util.EditorUtil; import com.ss.rlib.plugin.PluginContainer; @@ -35,10 +35,10 @@ */ @PluginDescription( id = "com.ss.editor.shader.nodes", - version = "1.1.0", - minAppVersion = "1.3.2", - name = "Shader Nodes Tools", - description = "The plugin with editors to work with shader node materials." + version = "1.1.1", + minAppVersion = "1.6.0", + name = "Shader Node System Support", + description = "Provides editors to work with shader node system and shader node definitions." ) public class ShaderNodesEditorPlugin extends EditorPlugin { @@ -50,8 +50,8 @@ public ShaderNodesEditorPlugin(@NotNull final PluginContainer pluginContainer) { } @Override - public void onAfterCreateJMEContext(@NotNull final PluginSystem pluginSystem) { - super.onAfterCreateJMEContext(pluginSystem); + public void onAfterCreateJmeContext(@NotNull final PluginSystem pluginSystem) { + super.onAfterCreateJmeContext(pluginSystem); System.setProperty(AstShaderGenerator.PROP_USE_CASE, "false"); final AssetManager assetManager = EditorUtil.getAssetManager(); assetManager.setShaderGenerator(new AstGlsl150ShaderGenerator(assetManager)); @@ -59,8 +59,8 @@ public void onAfterCreateJMEContext(@NotNull final PluginSystem pluginSystem) { @FxThread @Override - public void onBeforeCreateJavaFXContext(@NotNull final PluginSystem pluginSystem) { - super.onBeforeCreateJavaFXContext(pluginSystem); + public void onBeforeCreateJavaFxContext(@NotNull final PluginSystem pluginSystem) { + super.onBeforeCreateJavaFxContext(pluginSystem); final ResourceManager resourceManager = ResourceManager.getInstance(); resourceManager.registerInterestedFileType(FileExtensions.JME_SHADER_NODE); resourceManager.registerInterestedFileType(FileExtensions.GLSL_LIB); @@ -68,7 +68,7 @@ public void onBeforeCreateJavaFXContext(@NotNull final PluginSystem pluginSystem @Override @FromAnyThread - public void register(@NotNull final CSSRegistry registry) { + public void register(@NotNull final CssRegistry registry) { super.register(registry); registry.register("com/ss/editor/shader/nodes/style.css", getClassLoader()); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java index 8620913..7bc545c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java @@ -82,9 +82,7 @@ public class ShaderNodeDefinitionsFileCreator extends GenericFileCreator { AVAILABLE_TYPES.add(ShaderType.Vertex.name()); AVAILABLE_TYPES.add(ShaderType.Fragment.name()); - //FIXME - final Renderer renderer = JME_APPLICATION.getRenderer(); - + final Renderer renderer = EditorUtil.getRenderer(); final EnumSet caps = renderer.getCaps(); caps.stream().filter(cap -> cap.name().startsWith("GLSL")) .map(Enum::name) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java index 209807a..73d2f74 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java @@ -8,15 +8,15 @@ import com.jme3.shader.glsl.parser.GlslParser; import com.ss.editor.FileExtensions; import com.ss.editor.annotation.BackgroundThread; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.plugin.api.editor.BaseFileEditorWithSplitRightTool; import com.ss.editor.shader.nodes.PluginMessages; -import com.ss.editor.shader.nodes.ui.component.editor.state.ShaderNodeDefinitionEditorState; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; +import com.ss.editor.shader.nodes.ui.component.editor.state.ShaderNodeDefinitionEditorState; import com.ss.editor.shader.nodes.util.J3snExporter; import com.ss.editor.ui.component.editor.EditorDescription; import com.ss.editor.ui.component.editor.state.EditorState; @@ -25,7 +25,7 @@ import com.ss.editor.ui.control.property.PropertyEditor; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.editor.ui.css.CSSClasses; +import com.ss.editor.ui.css.CssClasses; import com.ss.editor.util.EditorUtil; import com.ss.rlib.ui.util.FXUtils; import com.ss.rlib.util.FileUtils; @@ -130,7 +130,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container container.addComponent(buildSplitComponent(structureTree, propertyEditor, root), PluginMessages.SND_EDITOR_TOOL_STRUCTURE); - FXUtils.addClassTo(structureTree.getTreeView(), CSSClasses.TRANSPARENT_TREE_VIEW); + FXUtils.addClassTo(structureTree.getTreeView(), CssClasses.TRANSPARENT_TREE_VIEW); } @FxThread @@ -438,7 +438,7 @@ protected void createToolbar(@NotNull final HBox container) { @Override @FxThread - public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index, + public void notifyFxAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index, final boolean needSelect) { final NodeTree structureTree = getStructureTree(); @@ -451,15 +451,15 @@ public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Obje @Override @FxThread - public void notifyFXRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { + public void notifyFxRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { getStructureTree().notifyRemoved(parent, removed); } @Override @FxThread - public void notifyFXChangeProperty(@Nullable final Object parent, @NotNull final Object object, + public void notifyFxChangeProperty(@Nullable final Object parent, @NotNull final Object object, @NotNull final String propertyName) { - super.notifyFXChangeProperty(parent, object, propertyName); + super.notifyFxChangeProperty(parent, object, propertyName); final NodeTree structureTree = getStructureTree(); structureTree.notifyChanged(parent, object); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java index 24b085e..829748c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java @@ -3,7 +3,8 @@ import com.jme3.material.Material; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.annotation.JmeThread; -import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState; +import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DPart; +import com.ss.editor.util.EditorUtil; import org.jetbrains.annotations.NotNull; /** @@ -11,7 +12,7 @@ * * @author JavaSaBr */ -public class ShaderNodesEditor3DState extends BaseMaterialEditor3DState { +public class ShaderNodesEditor3DState extends BaseMaterialEditor3DPart { public ShaderNodesEditor3DState(@NotNull final ShaderNodesFileEditor fileEditor) { super(fileEditor); @@ -37,7 +38,7 @@ public void selectTechnique(@NotNull final Material material, @NotNull final Str @JmeThread private void selectTechniqueImpl(@NotNull final Material material, @NotNull final String name) { //FIXME - material.selectTechnique(name, JME_APPLICATION.getRenderManager()); + material.selectTechnique(name, EditorUtil.getRenderManager()); updateMaterialImpl(material); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index adccbf1..b87c45f 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -22,11 +22,11 @@ import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.annotation.BackgroundThread; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; -import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState.ModelType; +import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DPart.ModelType; import com.ss.editor.plugin.api.editor.material.BaseMaterialFileEditor; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.shader.nodes.PluginMessages; @@ -53,10 +53,10 @@ import com.ss.editor.ui.component.editor.state.EditorState; import com.ss.editor.ui.component.tab.EditorToolComponent; import com.ss.editor.ui.control.property.PropertyEditor; -import com.ss.editor.ui.css.CSSClasses; +import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.dialog.asset.virtual.StringVirtualAssetEditorDialog; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.editor.ui.util.UIUtils; +import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.MaterialUtils; import com.ss.rlib.ui.util.FXUtils; @@ -185,7 +185,7 @@ public class ShaderNodesFileEditor extends @Override @FxThread - protected @NotNull ShaderNodesEditor3DState create3DEditorState() { + protected @NotNull ShaderNodesEditor3DState create3DEditorPart() { return new ShaderNodesEditor3DState(this); } @@ -239,10 +239,10 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { }); setMaterialDef(materialDef); - getEditor3DState().updateMaterial(JME_APPLICATION.getDefaultMaterial()); - final ShaderNodesEditor3DState editor3DState = getEditor3DState(); - editor3DState.changeMode(ModelType.BOX); + final ShaderNodesEditor3DState editor3DPart = getEditor3DPart(); + editor3DPart.updateMaterial(EditorUtil.getDefaultMaterial()); + editor3DPart.changeMode(ModelType.BOX); } @Override @@ -317,7 +317,7 @@ protected void createEditorAreaPane() { }); FXUtils.addToPane(splitPanel, editorAreaPane); - FXUtils.addClassTo(splitPanel, CSSClasses.FILE_EDITOR_TOOL_SPLIT_PANE); + FXUtils.addClassTo(splitPanel, CssClasses.FILE_EDITOR_TOOL_SPLIT_PANE); } @Override @@ -326,8 +326,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container super.createToolComponents(container, root); final AssetManager assetManager = EditorUtil.getAssetManager(); - //FIXME - final RenderManager renderManager = JME_APPLICATION.getRenderManager(); + final RenderManager renderManager = EditorUtil.getRenderManager(); fragmentPreview = new FragmentShaderCodePreviewComponent(assetManager, renderManager); fragmentPreview.prefHeightProperty().bind(root.heightProperty()); @@ -406,7 +405,7 @@ protected void createActions(@NotNull final HBox container) { FXUtils.addToPane(exportAction, importAction, container); - FXUtils.addClassesTo(exportAction, importAction, CSSClasses.FLAT_BUTTON, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON); + FXUtils.addClassesTo(exportAction, importAction, CssClasses.FLAT_BUTTON, CssClasses.FILE_EDITOR_TOOLBAR_BUTTON); DynamicIconSupport.addSupport(exportAction, importAction); } @@ -438,9 +437,9 @@ protected void createToolbar(@NotNull final HBox container) { FXUtils.addToPane(lightModeLabel, lightModeComboBox, container); FXUtils.addToPane(techniqueLabel, techniqueComboBox, addTechnique, container); - FXUtils.addClassTo(techniqueLabel, lightModeLabel, CSSClasses.FILE_EDITOR_TOOLBAR_LABEL); - FXUtils.addClassTo(techniqueComboBox, lightModeComboBox, CSSClasses.FILE_EDITOR_TOOLBAR_FIELD); - FXUtils.addClassesTo(addTechnique, CSSClasses.FLAT_BUTTON, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON); + FXUtils.addClassTo(techniqueLabel, lightModeLabel, CssClasses.FILE_EDITOR_TOOLBAR_LABEL); + FXUtils.addClassTo(techniqueComboBox, lightModeComboBox, CssClasses.FILE_EDITOR_TOOLBAR_FIELD); + FXUtils.addClassesTo(addTechnique, CssClasses.FLAT_BUTTON, CssClasses.FILE_EDITOR_TOOLBAR_BUTTON); } /** @@ -521,7 +520,7 @@ private void addTechnique(@NotNull final VarTable vars) { */ @FxThread private void export() { - UIUtils.openSaveAsDialog(this::export, FileExtensions.JME_MATERIAL_DEFINITION, ACTION_TESTER); + UiUtils.openSaveAsDialog(this::export, FileExtensions.JME_MATERIAL_DEFINITION, ACTION_TESTER); } /** @@ -531,7 +530,7 @@ private void export() { private void importMatDef() { final ResourceManager resourceManager = ResourceManager.getInstance(); final Array resources = resourceManager.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION); - UIUtils.openResourceAssetDialog(this::importMatDef, this::validateMatDef, resources); + UiUtils.openResourceAssetDialog(this::importMatDef, this::validateMatDef, resources); } /** @@ -662,7 +661,7 @@ private void changeTechnique(@Nullable final String newValue) { getFragmentPreview().load(techniqueDef); getVertexPreview().load(techniqueDef); - getEditor3DState().selectTechnique(currentMaterial, newValue); + getEditor3DPart().selectTechnique(currentMaterial, newValue); setIgnoreLightModeChanges(true); try { @@ -677,7 +676,10 @@ private void changeTechnique(@Nullable final String newValue) { */ @FxThread private void changeLightMode(@Nullable final LightMode prevLightMode, @Nullable final LightMode newLightMode) { - if (isIgnoreLightModeChanges() || prevLightMode == null || newLightMode == null) return; + + if (isIgnoreLightModeChanges() || prevLightMode == null || newLightMode == null) { + return; + } final ComboBox techniqueComboBox = getTechniqueComboBox(); final String name = techniqueComboBox.getSelectionModel().getSelectedItem(); @@ -778,7 +780,7 @@ private void buildMaterial() { setCurrentMaterial(newMaterial); getShaderNodesContainer().notifyChangedMaterial(); - getEditor3DState().updateMaterial(newMaterial); + getEditor3DPart().updateMaterial(newMaterial); getMatDefPreview().load(newMaterial.getMaterialDef()); if (items.contains(currentTechnique)) { @@ -1041,8 +1043,8 @@ public void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vect @Override @FxThread - public void notifyFXChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { - super.notifyFXChangeProperty(object, propertyName); + public void notifyFxChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { + super.notifyFxChangeProperty(object, propertyName); if (object instanceof MatParam) { final PropertyEditor propertyEditor = getPropertyEditor(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java index 3924e27..3f76a23 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java @@ -10,14 +10,14 @@ import com.jme3.shader.Shader; import com.jme3.shader.ShaderGenerator; import com.ss.editor.Messages; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.JmeThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.shader.nodes.ui.component.preview.CodePreviewComponent; import com.ss.editor.ui.control.code.BaseCodeArea; import com.ss.editor.ui.control.code.GLSLCodeArea; -import com.ss.editor.ui.css.CSSClasses; +import com.ss.editor.ui.css.CssClasses; import com.ss.rlib.ui.util.FXUtils; import javafx.collections.ObservableList; import javafx.scene.control.ComboBox; @@ -77,7 +77,7 @@ protected void createComponents() { FXUtils.addToPane(languageContainer, this); FXUtils.addToPane(codeArea, this); - FXUtils.addClassTo(languageContainer, CSSClasses.DEF_HBOX); + FXUtils.addClassTo(languageContainer, CssClasses.DEF_HBOX); } /** diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java index 41b5441..33bc188 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java @@ -19,7 +19,7 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.add.AddShaderNodeOperation; -import com.ss.editor.ui.util.UIUtils; +import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; import com.ss.rlib.util.array.Array; import com.ss.rlib.util.array.ArrayFactory; @@ -56,7 +56,7 @@ public AddNodeShaderNodeAction(@NotNull final ShaderNodesContainer container, protected void process() { super.process(); final Array resources = RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_SHADER_NODE); - UIUtils.openResourceAssetDialog(this::addNode, resources); + UiUtils.openResourceAssetDialog(this::addNode, resources); } /** diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java index 70f6013..26d280d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java @@ -55,7 +55,7 @@ protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito createLogic(techniqueDef); - editor.notifyFXChangeProperty(techniqueDef, Messages.MODEL_PROPERTY_LIGHT_MODE); + editor.notifyFxChangeProperty(techniqueDef, Messages.MODEL_PROPERTY_LIGHT_MODE); } @Override @@ -75,7 +75,7 @@ protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito createLogic(techniqueDef); - editor.notifyFXChangeProperty(techniqueDef, Messages.MODEL_PROPERTY_LIGHT_MODE); + editor.notifyFxChangeProperty(techniqueDef, Messages.MODEL_PROPERTY_LIGHT_MODE); } /** diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java index 0a3b51a..a2bf433 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java @@ -3,14 +3,14 @@ import static com.ss.rlib.util.ClassUtils.unsafeCast; import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.model.PreviewMaterialSettings; import com.ss.editor.shader.nodes.model.shader.node.definition.*; import com.ss.editor.shader.nodes.ui.control.tree.node.PreviewMaterialSettingsTreeNode; import com.ss.editor.shader.nodes.ui.control.tree.node.definition.*; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.editor.ui.control.tree.node.TreeNodeFactory; +import com.ss.editor.ui.control.tree.node.factory.TreeNodeFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/PreviewMaterialSettingsTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/PreviewMaterialSettingsTreeNode.java index d9d1999..2687b99 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/PreviewMaterialSettingsTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/PreviewMaterialSettingsTreeNode.java @@ -2,7 +2,7 @@ import com.ss.editor.model.node.material.RootMaterialSettings; import com.ss.editor.shader.nodes.PluginMessages; -import com.ss.editor.ui.control.material.tree.node.RootMaterialSettingsTreeNode; +import com.ss.editor.ui.control.tree.node.impl.material.settings.RootMaterialSettingsTreeNode; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java index 0fa8715..36e68b2 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java @@ -36,13 +36,13 @@ public AddSndOperation(@NotNull final SndList definitionList, @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().add(definition); - editor.notifyFXAddedChild(definitionList, definition, -1, true); + editor.notifyFxAddedChild(definitionList, definition, -1, true); } @Override @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().remove(definition); - editor.notifyFXRemovedChild(definitionList, definition); + editor.notifyFxRemovedChild(definitionList, definition); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java index 28f8243..3fea416 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java @@ -39,7 +39,7 @@ public AddSndParameterOperation(@NotNull final SndParameters parameters, protected void redoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.add(variable); - editor.notifyFXAddedChild(parameters, variable, -1, true); + editor.notifyFxAddedChild(parameters, variable, -1, true); } @Override @@ -47,6 +47,6 @@ protected void redoImpl(@NotNull final ChangeConsumer editor) { protected void undoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.remove(variable); - editor.notifyFXRemovedChild(parameters, variable); + editor.notifyFxRemovedChild(parameters, variable); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java index 6b24701..5d5bb89 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java @@ -36,13 +36,13 @@ public AddSndShaderSourceOperation(@NotNull final SndShaderSources shaderSources @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { shaderSources.add(shaderSource); - editor.notifyFXAddedChild(shaderSources, shaderSource, -1, true); + editor.notifyFxAddedChild(shaderSources, shaderSource, -1, true); } @Override @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { shaderSources.remove(shaderSource); - editor.notifyFXRemovedChild(shaderSources, shaderSources); + editor.notifyFxRemovedChild(shaderSources, shaderSources); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java index 36dc258..e3abbed 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java @@ -37,13 +37,13 @@ public ChangeSndDocumentationOperation(@NotNull final ShaderNodeDefinition defin @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definition.setDocumentation(newDocumentation); - editor.notifyFXChangeProperty(definition, "documentation"); + editor.notifyFxChangeProperty(definition, "documentation"); } @Override @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definition.setDocumentation(oldDocumentation); - editor.notifyFXChangeProperty(definition, "documentation"); + editor.notifyFxChangeProperty(definition, "documentation"); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java index b0a1907..a8d1d9d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java @@ -45,13 +45,13 @@ protected void redoImpl(@NotNull final ChangeConsumer editor) { final List definitions = definitionList.getDefinitions(); index = definitions.indexOf(definition); definitions.remove(definition); - editor.notifyFXRemovedChild(definitionList, definition); + editor.notifyFxRemovedChild(definitionList, definition); } @Override @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().add(index, definition); - editor.notifyFXAddedChild(definitionList, definition, index, false); + editor.notifyFxAddedChild(definitionList, definition, index, false); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java index fee3fb3..e6c5b61 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java @@ -45,7 +45,7 @@ protected void redoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); index = parameterList.indexOf(variable); parameterList.remove(variable); - editor.notifyFXRemovedChild(parameters, variable); + editor.notifyFxRemovedChild(parameters, variable); } @Override @@ -53,6 +53,6 @@ protected void redoImpl(@NotNull final ChangeConsumer editor) { protected void undoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.add(index, variable); - editor.notifyFXAddedChild(parameters, variable, index, false); + editor.notifyFxAddedChild(parameters, variable, index, false); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java index cbb69f0..c18c0b8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java @@ -42,13 +42,13 @@ public DeleteSndShaderSourceOperation(@NotNull final SndShaderSources shaderSour protected void redoImpl(@NotNull final ChangeConsumer editor) { index = shaderSources.indexOf(shaderSource); shaderSources.remove(shaderSource); - editor.notifyFXRemovedChild(shaderSources, shaderSource); + editor.notifyFxRemovedChild(shaderSources, shaderSource); } @Override @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { shaderSources.add(index, shaderSource); - editor.notifyFXAddedChild(shaderSources, shaderSource, index, false); + editor.notifyFxAddedChild(shaderSources, shaderSource, index, false); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java index b5d5663..4a16a09 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java @@ -52,13 +52,13 @@ public RenameSndOperation(@NotNull final String oldName, @NotNull final String n @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definition.setName(newName); - editor.notifyFXChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); + editor.notifyFxChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); } @Override @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definition.setName(oldName); - editor.notifyFXChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); + editor.notifyFxChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java index 72a6ad5..1bed5b2 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java @@ -52,13 +52,13 @@ public RenameSndParameterOperation(@NotNull final String oldName, @NotNull final @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { variable.setName(newName); - editor.notifyFXChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); + editor.notifyFxChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); } @Override @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { variable.setName(oldName); - editor.notifyFXChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); + editor.notifyFxChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java index 06d3699..90bdf4f 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.dialog; -import static com.ss.editor.ui.util.UIUtils.consumeIf; +import static com.ss.editor.ui.util.UiUtils.consumeIf; import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; From 86653b9b636a2b1a7d07dfa4c52ee7a820ab5c5f Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Wed, 21 Feb 2018 09:48:27 +0300 Subject: [PATCH 09/25] working on value mapping support. --- build.gradle | 4 +-- gradle/wrapper/gradle-wrapper.jar | Bin 54727 -> 54333 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- .../shader/nodes/ShaderNodesEditorPlugin.java | 4 +-- .../ShaderNodeDefinitionFileEditor.java | 26 ++++++++++++------ .../editor/ShaderNodesChangeConsumer.java | 2 ++ ...tate.java => ShaderNodesEditor3DPart.java} | 4 +-- .../editor/ShaderNodesFileEditor.java | 8 +++--- .../editor/state/TechniqueDefState.java | 3 +- .../factory/ShaderNodesTreeNodeFactory.java | 3 +- 10 files changed, 34 insertions(+), 22 deletions(-) rename src/main/java/com/ss/editor/shader/nodes/ui/component/editor/{ShaderNodesEditor3DState.java => ShaderNodesEditor3DPart.java} (88%) diff --git a/build.gradle b/build.gradle index e783736..da72aa3 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'idea' apply plugin: 'org.junit.platform.gradle.plugin' group = 'com.spaceshift' -version = '1.1.1' +version = '1.1.3' ext.artifactId = 'shader-nodes' @@ -179,7 +179,7 @@ task deployPlugin(type: Zip, dependsOn: 'preparePlugin') { } task wrapper(type: Wrapper) { - gradleVersion = '4.3' + gradleVersion = '4.5.1' } defaultTasks 'install' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 27768f1bbac3ce2d055b20d521f12da78d331e8e..c44b679acd3f794ddbb3aa5e919244914911014a 100644 GIT binary patch delta 16166 zcmZ9zV_;p;)-D{|wr$(CZQJ&4Z0^`jV;gO3n{8~nNz*T<@4er-eb=8g=A6%Z)|z{d zse#dI@ZPWBN!+jixMpfm5D*ZpWD#}PtTWs@w_7(*kR-gu7D8vZmdi!ZK}Zk~ZX{q* zF$u6>8Uc`}rSFZdiSa>&n8ks+fo8Mlh7DH=>$s#Rq9;nzZpSQRPcIo}%T^w`sF119 z5f$@%&ir$j`*0ZA1-52FkEtNw#`;Bk=~|&2C`*;hMC@l(F!}N1{q*r<`|VVfbH(nHBe-TCW!OfCMp?le)_ zoKQ7(OqF3H2dw|O_h^;6I3re5b6XiUe97oZ(O0daree&?&P_@_$Gbc{?j^S@={AnK z_%cAawLpEEd-_#UauUpdeAMZ%fu(FKFOY;W#kil1z6^5PD4k_%Y_^>#U_PJv$hStXo6Q@Q z7gG*&Dc_--yC7nu%g}w+O^(zNZMI$sYo_HyNt)>!X~i<#pR{`otHy;Tul!;HwF1l_ z2Nfo*^6Y%7Sn*W2y*)_d_xYn9)bFI*?c8fYo~~7g)1zx_@@yf=eV48BU8+@MAqMbD zTWg>NU!%vhe0O8U5=A3j8uQ)BNEiH+WS1`@GUV&|q)LdlpefFgA^>bd4cy^-?am5@ zb7cm?w70~(Y~hMwuF}gd?V|H_y|)C2$EG?crBb|7>IGMtN8ttn-PvqR`ii`H$@>Qg zB}7;aNNCs4;(AG*iu4Rz$$q7a6jy+HKjVdFgERuT*9_ISszoo6GUC(chKWsC8*sDlpN%y2PLDKjG?|tb(V6?w6iei=L zo?vz#X4h_Dk~d;}0?0{BH z;Eyhlp!S;&bv)>WFFEjtSbs>!L$g)FN9+oY1MX_g7ghF78O&n zmY^c?d5+T8Rfwe z%-!4;K~v&@Twg=5Slb1xA{%zCE=|aJyTgvk3rWhG{GQ0Ch)U{e5cJG#89Ma}e1tKQLNAK_*8Ubr5NRhQXjyC`CaOG#lBOD{2EEZqF8uBhXfO&lnDL z&=bxme)U{M2wyP=Xp^L=Bk*n)-xNcJKT!Er!Fes!Dq!DZnyUW>;SC_(Z7aaj@a@;m zWvb^{oOabYAlCmm#XUUkBZuqidf@SbiWWS{c;}W8fYJo*TF5Km4YCJETE`WhdF!M^GpU#>$;|DKcQ8`XZ}ZAw;KCQQ0y%FGP5}u+JW?C*D=f=s zm@B)Lx*^oKP{P)zLXV-qE`_MQ^sQkvAHFf=DLF6l;Q$Q+dx5FvHmss%TU>$e!8n*?9pWTbHz zpbD&ruVs`pR<`fzD$S%^R!DgaE4N>v7C; zIQ6ayAh++`coJProe)+$w&<8)xTR?`-Rgv_9Cw3or!yuM%e41G*_p-}qx0(tB(HT= zwvmjMJk*w8{QwoQK#cCs=<0zIX6v=50}V-=^`@GYc5jCivV4{=ruSk(J^nth-8^CK zu6-0QY(pqj#{{9N>|Rqnd?mLruv+T~cMmV~fMEF`h&iUcN@Dg*OxEL3fqd474$Dx} zt>t9wU*%30XVj@8&$e{Jb-R4t4#{?_k0IgeKSL{M%{*69)!CO6)AX;jBA9g}lHFT1 z1zCBy%e^qw1&J1IV~U!eVbi+(F_#&@Mx)LY#*dfPXgRPd=m_gdSfO%fwi;WCd%il{ z11en=L7NRtgWRqj`I*X5F*b^tsZ;^!$$a5^+L62ugy)^X{vN zKd50#n;T({BzR6};xxHT6UpfqQHCpK1AsSMfx^5)w4L|s^*jXgyv7T8*zAqew?fhH z-W*nD!gH=5uAE}orLJVa?sEgu{PGY9*qoQ4(ndj z7X}^&N^tG-@=h*SNUmUzgwinHyRa^)A5F2kaPb8gmznE7GVxzcxzs_Kh=OBrNYr?& z+)erIW+YKsoAH`ip-z)F59*FvO}KBET0e8|X~ zOwgMI+icMP2K~>d!TI8FtRx7-28x&E_`fRA5K;3BB%w zaSGx9-UW2*6xv&K{q745ZTdgjdaMIBNheLlYh5a)1oh8~SWmCl5F;*nGx`n%efKx( zlFq77(%biLqz1{B1@L&$*kuOrW9uqv?ma((Huau6kGbO!#DQhn?~L4pOm;_I*XzY? z9IeAiKaCWrR=LLKj$>fNhB+gG%eUg>fI`cFhUMTbQmp_~M~BWoPMLraO#8YQb;YB4 zgmnI8EMjIn*D7+X=^R4EJ-Nc z*REtqW)4hvgxJOh#9O_NYl+B3{8KJU^DPZm`dG;=t4v;1WHyBYi#OaO1IC3yCA^g zJ=KZe%O&x+3werZ)v)ZYT!W(;-k?v?{Iba*L>@-rB5x%Ni-?i6tw2Vqun0J9h7H49 zR6zDeFqBo{Z>WE@RK1+*^b8yXBmf=+L;x5ZOaa83#Rmoiq5*75MM;>$KAYG5Fbl?OE#!AwvdvIsZV{4SJ6x=%OS zN@{T2LAp;R1O%|gc_#G4p>XlQ5wzn%U0y#(c_f&UIqNNJEUUHK>s6^Os@q%j*5PgX zZqGSYYl%0zg&D0NZud>O1a9DePz|s;d;fG}&p}wo?yP0aMTv;F>aEfBUUG|PDC*Hw zwa=+4i}jtPf$c)r)x0dSwO#e7HpR|4Ojm|FEH|}T(E}(ta&Uw&`liG^c}P$rYCIJR z4xI|Y4>s6hI4(EAD?4m+@bsDBxQ;q8=(UWmu6TST|LV=Is+8i?Y+>B~dep_pzO&RF zfDZl5PBYxY@Z)4N3n^d14f+a95&o^bG6=k#FwsLs(`J~5A;&-=p=1msV)U9Ktw*;a z&*NS&2OXfO$8nD^AN0gJCfRJONuwx%l;CA*6}|pD3ZmK>XAc@$r?G0f%W6%#K(l3~ zLU_{+*S1WuNvb0%$33}nd}N71+=W>f{!m(P_z3W#6&%wPrDNK0;#>L%j>NIyFZxpU z%VqcSOjI~*D~VoNQ+`wVq%i!o#Mq@vd*{^8X0L-J;;}DAIrZZCBQvpL2z6qNo&0=0#*b7W66ZTE!J|uZAyl zSp}e3>bctXMv+RRpO*8SZan3*|9)pzuC>~;W7G)sx}cqAkmwuKHQ@UnN~b*sahSA&sDMA-HYpx_Rupk748 z$&RTjFo~{rh}IIz=?)0Q`v#NeKX3*>9yb6?rD_8GUMvl$Z@7KfI0`)w&%4M7mSwD` z%B6<)jl`%M;RZ2_94O>HcLCUgWpl2lm`bVd<9qNB-Yj=-Ok$LcMS+k3hkwG0uBOnL^a}Q+Au+#u3 z6uMoW9bmOGOYYK)Z51npE`vvTEUefINQ11(XYAH3KTjy7VtK9u65$gPV|m1X)7g5b z1zq0JsL>^;yasV4qJ8FKeU++)ohW*i8w{9|yp3;Jj*e+T$?8u-=*TO|kv z0n@)=&D1zq(TTqb^Er==_dUA!Gs@#F1G^!91Vlfz?YE^yC zDe>zQjr5z9FPI;s%sm*<&_nEiu#TAxEfhr(8JdZiiH(>uX_UbU6_Jk;WGRkQ~^Aa1=lU35~0Ri z96J8)_D|o`k2P{p1pHVG)(gf0tUaGR^g44bCiUiAk+!mLoM2n-ZiosiU5E9B2LC5w|4Bp2O^% zhB=AJM1@K8wJU=ps-*tFmsS951@P0xf;F5+DH6x*8tvM2JW0W(e#!50d7b!zb(4M| zJ&E~auMXsM;<;v3IqYKT9%u!D{i|cn2E5;XK!JcXpaMy=sev!E1b}Uw)BjkN{`7KP zhIxEPqtQ``TUg-Qh7WEfr@P{hN?nGOG!S)^hg=Qq zAo%lnZhn#e`aGksKpET;@GzP4eAT`Aw(b8TaQymDz&+s?sW>PVNJ}WhO)wa8I#R4J z$aLyN2c$FN+{k#yn}Do8q_D8UeiSF53=ybb;*9bIFCujz;JMf-!M}wWNRP&%WJyH)>*0oYZa5R!L%G3|uKW1N)}n5{Y%AK+A20d2Kx1!`Q4O5Va`o-Wg5onz;u z)!-4u(~1}g5%x<5{&*$%m)VHHtr z*HyWvz3?j}>kPt*^(n?ydI>Z~0iHucX>+8e!>(Svh7~Y-PhWlIg(RNR3!A1&>!PMb zqD+sT$9DNf5XxRX*3hl#9;zMTR*$~1#74f(Ms{r(71j%e^78g4DZjH5KM!LD z-{xmgawHW|`dvd@r2Q*VW(XdfPDL_D$r&SF#cK~jJ|9wcoYfYMIj7Ulb$u}R5wUf% z>>hg>m3KG!0#n$d!V< zPYEqLUyU2Zdduf4hL?0sLr$~sNd>2(Y62(VBEs4rJqd z4)>$zHDhq3UN>Ol1a(U=Yg_mCgrcuz`;iB~AgX9cxgT=A+QXzAXc=Z zk0q=)X1e`4Ra-NmK!>Eu!1eTzG@hZaNWR`JxlfTN*l$rW0me>^A~U4nAJ_NbI>`*c zdcfGoK`ka0HvQ$Q8AZa)mkrsu%4=-rJ(Izge_!S#Q=f8fn;)q;JiH}FI4*GYwZ$F1 z_KCEBMntj0560J&HRSyU_oYipg(YmjWg4Z_gh2IN- zh{%O>G*1-d9!ecrq$*QFp&r37-kvTX0&FEws|GR`_bu;uYVAJ2dZh0y7uVldWM?}> ze^E#d2|ytbR}8M>1LdaeQhu#JbvA(vK&-syV8R!@eO?~S%-cY+a$4+Z@WXJwYY4}f z7R(YF29px$L6#*TzZM=sb0wJGgV-1voq;{-Tv?=!G9la;;||_z*tvIw_f-ZYilhQD z|FFnGsZKmeu_~LOu+N$VVTby^jz^bU-`);m4|$@I-j7cwEyShu!@$rj3w^YFn_N) zszH26&-eX@uq__WU{kabk}H<`PV^^*B2=_hj zcd`$c8#}6pC$$O3!onkSY%DW!C+a+F*g^hW2tm>4s|6T-c+l~;qhG=P;SIfBYz;v(-)F#->F{2!r>84Vnk3W_~ycB z>p1oPcS1O{%5kBJj3mbwJqQ=Zz>K$-KPjMF3IyH@*uz0n71v5P#%$m|gV-;~|1O5S z^1IKaK;Af6fTQxF3dZOkZ~W~QOkA3%M1_zhXbXg7(!%JONF3^H6PA8$?3JnPD=cUD z`IiyyU$z0H(FsG?K_J4Zw_9yfi0KIFRF}N%$L}-d8-HzXDg#vs5O;hjG!(Mgs%MIX zv{O~h#VJR7nTh*Yp+^@!>EwGlCOAR6lgynSik*Nf*I5ged^ppIm}$dR4_vIOgc|Jg zlvRi34oCgrm_-{G)oQ%~g!l3UQ7xK@DoTcHB5~eLWRmuNlxiN%32PbLx=XG$h1VG8 zbq_W*&$iCq{<5-%8U*xT!{?R8Bpmd$I* zO6zg(JIcaYn~lgQF1TeJzRmz4c!taRcQz`(9?6Osz<-FvJsXRCs-Q0z0oc3Q&k`82 z3lXoRbG3_f`tjY{K|MTcGT+bC;~Qo-qPh=4meI`E95e%Ls~ou<9))exSJ?S+7F%VR z*g5tzYv`y0cwy9SYEH2ul6xB8E0Zt1kuwxC3+p;23GNjA85rsFo<#ek9=u_8uVUzc zMrX!+sMaNaM}penc^6RZKqN=mF<+@$T5yCT0LjLXh-o?Ov{;4KChJvqeNPupoD5d{hxMa?W+rTw2SIQcCbN^ z3@AlYx-bEXNt?L_@P^;y;~X1w4$f=Bp5Jcex`J)L71vy6m1GCY4%zTf;;=rV)0<+P zVQUR&E>NFFd+ZVatG=PXP%5)N&kI#hpL;n*pkpEqVBKj^1x1kCb$`fJmc~(MLTw?H z>MDinYbp~%S@BmjjieB=wDz1K2<%a*Riw#^8_1p;5Hv^$N}(@_VpEEWGHE0kF&S~z zM^n5&e)mga;ctP^4N={&6s(n^(n>;#wh!)#gB*8wa4Z^AHY%(YW=7&*@N`(3sW>T~ z?aO;gfD#8@D)F|97^_BFpFyrz&rLd^y#aRo8~}?w0_&fw!$T~nLVuS$G1B?-bo1AC zT%v=)-QBxzy3nRmuCME<2p28-oazEcoH=CVmhCf_blB++p@n3dmSX||yZUv_w=uCI zwR`RbcfZ>9GtCx{@~zRFC|f4COsIaY%Dmqo$W|{m%$Gfj{-ye*$ z0d8}3j0G+c2+e=o(&?@~tSn5WS?He%?|nblLZ z)yTziu~~>%>Qk6iS~^KqE=&<=5#%*lSP52`?GvI&vOX^2~_ zYY**^xr2CW`>~1Vjs76@{4(V9(~h_+JKMsU?_&g*B5K`?H`MDf_+ehrr(H?tjK$Yg4dwUL;sj--T?u2DBKm`i>y7}H5> zq!PD2(LDxmJ#*vi`FduE((%4g4T^+s9(gr4T6a0e3C41WV^&z{bVp1M3u(xG@L#c7 zcp(K|tx;CE+H^!*cOXl%hZ%p&;cMte^yG9FR{7uF?Noz;9k0b8W#eZxjJs}st9nTBdl<}46A=JwV(T$ zkdJBfO?NbVo2&%%s+Xi&*02|bCo;&ZVmn6n7FdrNLQl`>A9`-y^Ln5uR(SK$o&J<$xofKYOI%NXkhce2Ovq45+@mec$8{nYN*!l+B+ z(_ppq)pBZ4zox)x4x|^Ha%gC5-YLopuhs+5nUpCcc|i`#im=!$O|#A&my`|h6j{4zF%uS@wjdBO0&yUN$MHK zA!E`g6oc`S%aoNs6O(@<{yQ<}k$bcN`O{n>07b$T%?)W`ppb|jabl@J-V7-~v*V{* z%97Ez*al9^wmr2hs(=K~ULg)bfd%KCyTx9&Y1`2YyCiWB{RJB>SOT5+`=`&xx{G9v zDqPt6s+awE$Ng&R{o`#P`wLwD^FCY*9!36egu9-N00Zt8%WP z%B{$-cmxD89>RJW;YYMS(=#4m#SeqW$UM1d)>$&)I=T74N2z6s#qdO6HH+4Xg`zrW z+X~0PRlwh~z0(r<`X${yRw*dH8(+Xhf`A%0--gb1V&7!ijSyZhIEz%pge;!pRf{QX zqZ9vS)o`<_GePq)NAYS|GPYd+=8^<}rwqo1$nSR=#+U)nJybknH=qG{p=T$&x7F{V zg5&HM$XGiIVe-Ns-siGlnjYcaVfV8l+~`ds4F*`6Cj49;pj`IGtg3zM7M%_{j4Dd> z(#XU_A=EZK88ef~9OZ*DMY(s=9Y!aN)iJ~2H~uwTx4&{JGOEsS-VqH8rM2P;j!u`) zn#wGh*Z*P+aI_z-lSBZh_gYIican@a=2}a44Mst$zU)M|;YxKGINgHxy6xDl8|9sN z@y{j4a4u@N_jZs<3p0s-(=3W!;2EEcpQ=_K`YAH;A}OD*)A6A&9)caufng;OMY@BhOMKEWW0v z3KH8E5Yr3$ood}eAodnBLjil^KksQ7EmIH+k@fH=!j<9~YFY~&igh5lU`@St=)Us?k?6Pcr|=pFzZ7bv$VUJWU8$)jhZ?AMRE` z@+-DjgKM7KW`N8q06GVD-9z@g=)0OtNBOT|ljQttMR!&STMA zt@<5=z^wto1)gO65r`|aUV^(0>Flg^vb|2GTh0wunet;fW0UDc?}XqdW2J&Cj7b~+ zsvL_vitDxn!yjD^&@ST~!O)rIf#AsI0Yr&ryrDT1)MLU?WKyy@6wy;4+ghlU3IWjn zqmY>Y*M}RetM~@}xy|kVG>fzS^^VOhpfaYZ|8QPV!T3<3#ejE*Y_D`z-BK}eSbDW$ z$(G?@CEY}uB6{))j_{;yKWbwKn&eRcR;94`x!l&qOYHVx^Yy;!+n~5H2cC}B!({pG zhnaW{6iMq`{#xMg!Fd*Z6ny}HO6}eifuI(9-N@&eewj*y2{$hyQ+_lm;X)2tGyv`*9hz-L9^Ladd9)Rb(*?IN5#b;+_+*U!w zx`U|x;Iq4E&&GO+S(6?Yi*0BJDEMz}e*-0aob44=@acO$fZdGE>DFS{hI(efy8WqO z{Bwc~qIm$Ijr6P0 zxKo?4NZ=4QL%gg$`}hn-!3Aak15r^*si4wcyKBxN6zP|1mj z6ap*`PC|ylAB0kD4FQEy4h#okkZgy7d;B{Kx;2%U!I@EY>qZw=&GLd>)$$4_Y579m zO0AIoo6%eTwded3W8ZLDt)WA$^3L@ZKYNxe6V+4Vmira&kLNt+-`m#;Mjt0xB_LRn zz|OVM_N9HtM;~dxsIQOqptHxzOnf#1R1eNhumwqc?S@qnY3(S5 zNz^N2F(53mslxf>Zkd$RPqU}yR3p5>)rM59szw=xS@i`0A#&eg<*uU7TvHYnk8*(2 z?v_NvFDgJYLQl6Qs(VicAY^u`jarp?cy4it5fCm(!mng|Hn?ZZg&+{PWOO1wKJ=~bx zW1kd|-J=CS+mHB?#I8GuLesoqkxun#i8oqb{%YQyTWMttdEjuEM`bvZ?C!ZvG7V~5 zL=_k5uw)5zKpOM4Yt{rZg2BX<%M8WT!spy}U}8^gt>wT-lGjG-&@A*ab=9xNWkuU4 z0Pi91SF&8IY0=urZdJ%UqB+xLRDQZx-#KDV2?+z5xY4$WUAefk8apuU6*FPwfsO*V zTl*J=B$-D|TU0c5NW=RA8|#iyo}2nDWkvL+!@0{HRGX0O7isL`jXuS#^?81m?BsbE z4J&6cBQ>n&*%vbWg{I$do112~X~!n@)`r2^dnq&fTo=>J;~Bg4@v`x~o$c0|%5HnG zL|p)bME7XTZOo`}t0Of|=OUM%Bc_&&9zwk&p~?PDovqwTg*&IWblefqQ+i6mI1Y=; z>blOuXwa&(dj++@Oq^rIaFdXoe^AR&nnxq2#ZjEbjCZ0=M=@)0%7v%v8?VRrGlees z!gtPXquCg2@A8bV7g6iZ=i;u-f)4Z1A8CLh8Jb4DpS1MWslDgLdFcxU)U6Mf_U&f+ z7)6CH;w^&+&Yb3?kNE}!c*bh|1j7CrB zr(IFSb?gM@Ov}`c#rm6?5UQv~IT1?T{H*t>knmBS}p(%tZ5Yw z15EuwORNigMH)E#gE+N%eQFA~vD>)BI0|h|#o#uJdi8aNC*~LIH*x1Z{j5 zQQc)N@H($iA9Q0`GHs24$l)|w&D{H^Dsh6LMN#^v>4QIZR+r1n*!;Id?Jo&E4KjYs zSp%Y_A?s>XB5GaRWgL|jzA6I@=1UoQa~;=G>g`ZJYpTubdS95P~?K zZJJh-8ZOu=$W#Z$*HG{l=&={KmzN`k!fbT~cZ;$dzw*UaR%mKpcepIq$%+3uFcW7= z{vAP(6eP}+HW`I)X}@7jI8DYSrO;fCl>sDqU>Cp1L+_o`%>7?`M0j(azQ^-x;rA~cxXQoNPUzlGmjIi9(8 zlX{Qk(eeY=aM$fUso0Yad1ZIaojD`6D7~$-7Eofde#2#PzLEjZORCns3-1;n@_r@o zk-1_$kaugRdd7Qc3|LQk8)>NM-$;7X9PyRkFH5c&axa`qs+Uw?;G$`G0zNV8V(n>1PZFU~r<@EwGIKyb4V+c=mAFm8C4j%zqm73LaipC}#ik87oIFl@L6eq*_8L#?15 zB08U3B&AlsUh`Ic-_|;RG?w`u|MF1A!0?l8_!>x{AfKIum6-! ztS5=-ACrEl3H(N5tJJh^&mzdTsShvD_;^aS)v98)j1Q;ouCK;h))D*WFlxJGqKiEB zzb}R6UobCERQspnpIb+PyxJNo2OB^oRog7n0WWL-`bWC`*K=g7*YUwr;3Y8=mg1g~ zz|lv2I9c8bsHf=DLMavIK9%>P2foCG8(NJg{4}*7Kl7_*bU}4pV$fpW@5T>9OX7-x z;!F{;?7pG&&Z_($j+AQ|aaHyFf{JTuKKsYRef;z06|{s&*zqkA@5 z@w8^|9w`Q$QDt?H$KKs3m)d)&br+M1*KPhb-jc12dlERWxZ$W9zOcXeTIhLksux|a zRXR9vmpr(0!BXpzyp@~6%_*M!iyNA?Y%wO%Ow0OLc_~U^BEBB<;&R_jkivZTdr~40 z&svb(AfYr5c%CFn#DUJ-;DRR0F$>yAGb#{CA3TK*wa%bIM*<4n^J}CngZdu zrU$SQCJ3f-_b_*xbX68G>iTq%s^8B;xK9X2IQm6>C8yyae+)nP8GFugN8v&r&KK4< z*r2c@7n?vdZ(y8Xq=R;5O!kZBx}Z=ev7M0LMu+lL?hrp9n<2q6QTH3<6jGhg19Ui} zd_99Ao1!p=W3=GyMEiW1n|zh27IiJMo!Rpo7X1Qc)nX8Tz1w#ADx36^VkCEkEk!1A zhp0vDr(P$8OFRZydd&&Ph4Vf);W7l}X9oBtNXYnRp_>f4~xI}Y|Pc4+|kCBTQ6kS9VZ z3ryasNdBl$KW3i%aE-jeyuO8ufxkidiG;5AB#qvsaVsoSAgV)P;JKpFxGz4)7c^s{ z`X#j|oc_?eL+j(q`C)yBsL((>FE4{~+FK}1sZr2YVo;2wMZud{jb1> zdT>Vh&SE;F>Kh?M6R+DJVw6tPBIt~jVJ^#>VR7iL{E}O{WPm+80Y&CbvLX3t z&bmvD4%RTr=`_Y=>GPg^KI7#2G5<_T-2;8K>w3B6l}cWm5nJ9hue`+9H@{_;bU3{# zLYDrTGm7*j+OSHzp;PeDof@3!@z)2glMIkRwv3n7D04#dhAh^dkxWNxgtR_>-1^Qb zaB4a}cHgL%W74(sT>#8!PiBPL$T17!mO_lFz+kIprupcUxx9?&u~OXH8m`F^0DpFY zy;6pkUfPj5C{k{d=+>cBpt$ng1!8i8F0vu_Mps$Ka9#?-fHzE&aoIM2aKx_548s1T zi~X#3xsCfQ+Ef0@5O-ZV! zO`>+*OMD*+${mM0l7+$b#kXWra=$%M5C;Jx-xI?69;0fmbg1u(fc_JyP57}(KmHWr z*&xqq$q6`Yl7RZF>9!{NS2J z^JZj$j%LUD8-QWP{{CycmgqT2+g#zHCawQW1+64RZ*BM{K}mq_f#Xi8MC9$-w89`f zk#fb)G6jYPA9vk8(R3%?SZ`Q$Gj#bCi)bmG;x}DW??#y`^DF|(f!}ebkMiXcISK{d z9e1FMhvWgu9svbOFS!^$eR&a?$8ddAS9U2+N02RqjR5KTw=n{V#N+Zlnnt7!Wj`;O zYN&_MYFscuwaXlsW`kgUlmx_A{7AUo=Pf_Zq3ORbojj~`zX_RcjP63XnN9TLK{?!C zk3bB{o@$-kGZi!EHhq_T|6-p*J8z^en@0yfV>I%E{m}i8wKK!@!4 zr{+LoMmj)HzE?A=vY0o%q~ut*^zmIfq{@9ox#MVzCp-OCJ-w_hC|>bN_}iY0pvw%* z2F}#w^v-e`^MJ9>Ohk<7#h8PFO16W-S)e--X?slYPG_xL;DuLZmi6QJ##NkkcZ2e>Z5(mfuUI#B4O&e_YjeLzL}rL4vc_So1ywko0@ViO^0@)!EbYIB*(II z#}#+R&)x1Xg)BUXk_2j=F34|59 z;$O&(?v6i%o5@=Vkx`e~AwX2*p<(F2bF?u(qhZm3%0qJhO_>E252=IZ0-uIhLB9iO zhIv5Gfu_SEU__w6#t}@QA}Ah^X9@*q0fmC_`RxC>bf7*P34w`FFhJ=s6rc?B|Jx`4 z{kPF!L>x2^*f635c8>kGf^bv>Y!l}%D;zG#U)FTu|M$Td;=he1WKh6w#2CQqQ93YI zvcFXpc}j7AqoI!ORD(nSYWPon@KC-FcbfFzTe zV5pWrdP_=R?j#+k3vhH&0Ia|g*lEcQBwGIL{}di59ngHr25i;=XgW&(Je?8+vvm3^ z<~Sk$2Sf1REMyQ6s{i|OfA7Q2e}M(lTwqh4pCUQ%*EBZ4-#oU@RE7yy5D@-<@Eu-% zK`JwJkpGjF1DL@CQ}p{km5{)`8A6EvBtigx%wU0u1^%tao2AG9-%-*3C5-@@%<2;S zH=-2;MDV|jpAvQ0Uy_$u27=K>1BU;p(dW9=s+_dks4$$x<+DJZ}%pTPe(11ms5K*~RV6`p^9wyA%C zPHCur8UMNnKN)jBlfK#i0a~Sh0-1rx3s?ky-7}vc%}>z3y_L`U1Su2zV=e!Og(CNF zPiGfM3I1b4-Th>7f(8K*{s-ir{};r($VBj8gX;hO>pP1+L1e(3MHaA(W+3Sj8Swg3 zbngBXb-+CPfP~)#{wmn$5+0cBci?S5|7Vd7j9>sLx6DfL{}1TT7vuc%a>oH+#xfn$ J*uZ~k|37gFA`$=q delta 16621 zcmZ9!1yCGYw+4y?cXta8!QI{6odChz9R_zFg1fuB!{F}j?gW=85}GDzrKaY0UiN=*uEGF z4D1LAIG0Zfe0M+rxGZR*ek9{g)Jvcv4(<_?2K>O-#D+*#rU}s_r4XJkBAYE(EsZNP z!CO0?|NVZ4;d!PvAxC0a8X}W^_7E99{h;&^-t-<4(El?@YxpVFBb13xj z@yG?nbg)6wVk|pEpweVq0jbBb6^PeGTdeciMhqgfA9Tb3IE;;K(Af{={VtU5E@#%2@4F6W=-p!QSCr~|o!B(* za&aJ1Y{vmDz>75nqqxeB+X!l!?YC(JAK4yYUv-te;zbMDa}BF4pxvq&@7)lbP&sa)!Hmtitjnkl zq0=y?z9)>B5lY~(e+>dhxRGDimATtmPbb{cFqv8twuzAkHE%XY(jdC79;(}Q{3tFc z-!y<5va)<)u8&8iMuX@|sb*aMe$R9~d-5|Tw~avauDaBI6}vcUY?2ddJEsQMTu~a@ zb>1Tz&X(y#IMa}T(A@lUQ_F` ze+Lm?F8zWNT&h!&&E0cpe-9EowiY-exI7^8P!mIk{Psux>b&q;F2?c&{=3bKInOH{2tw7vx<}1J90Y%gbL~%48cQYRH<#fvZu+!E^V0 zIk7=QV=SVbkUFaI%HkrzEMt&@_N=dAsK8Cjh`M)pOp#%l3_ z^(#E%&3DQ0pzu{uvWj26w)~F>qQMih>&*A3xxM}ct?s5To1w6|8)riOW!`% z%&ABZ*Kp%g1JQB36E6c5(^g)SjpLNb?RZr$(DdLIj}cr0M%V-=iR?+CN;7zMHYUeJ zV7{|am$K~hzAh+e^NUeuZgUKu1KfndQ&KL_m!}+Kg``-!Lmqd?GOn-n2Ex)^eG7f5 zWB21wZ=CEfQ06u)H!jk?8LJ`fvV6>b(Ze&w=xn<%BXO@2_F0P*G53t{>XA&dc=3R< zaEd)lAA;Ka3T1tSV=s#KaV{W6FB9OxeN*B-zcX^8hM5sBTMtVWq_03iKdIUUzN zbZs7IJU#ZTEEbPy{aGJq3GDIq@OkW6-9-8QB!(cwrtq$Boukj6ut^B)ocr4DXYVW% zFC)fC!-3@;B;L2iz`Nk*sg5#}HbVaSFho$Q#GWo_NN=d}CmbX8Cvyg2%9ai1v-OX| zp%fP(a4$Fmr)=2PEV#3f)^FS9+cv853_lQt*58-Mu-ZVG6XsTOJ?PZ@ws6nOHCs@s zz^Ch=%H$fJ`9t7@+ixhz7T9M2;DoyjKy^VG^+Qn)wg_AnYLL&wERUfH3a!qQR)bNM zMq6U;d;TCk4IB{q7RwiG2hze-Io;{cNlg5{827adJf>Xc0P{g^qmTQuuZ2frCr|H( z?{8$%FbTA&2=;k&tht~F=>`#|Fh{w*x_}LRHagM1v;aPcVF^zsrI3i<5X7+30OrL^ zhec7+@!9P8SbYkM(Mm7Mq^ZipqMmv(n@U;@HEh$uJY1&+Vl9rPt`X*?3)_#{P)b9F z`sil{7SE)&ihq=ra@TCpp6;}l}4eFd5dOL z0^)p339Te66AnDQPAvBuE;n*GVE@4!g&|%>!HWV>p(BOG3?%Q6QBeaY&Dyly<%dP9 zFyOtGsSDg0Pwc8X`ii%p+^pZFKYw!Rg~$22n-WW?q>o4J$FtQyT`DUohhw(X(`|== z^D6-y@xtP6FB=rCGqmT8b0inT6pR?CJIxY-=QlA*2c)Y_i(}0M&mo2b_-6rk#VP}& z(5YA`jdTYPiP>Cv%z}+4=MpW}J4zgEMv{dsD1U~?wM`Ob7OuN>8MQ$8N>NGxVmZuK z5Z%ui21UuPUwfn2YEMeeV8$kVh`VoGNT(zR8zIxe5K<akx=L6It5;*TidZz+?zJh|Y5iX#i6N0G=&UJ-_ zZ3T7sFhLL&VyMU7hqMpQx|Q8AZ%YL4(-*@O5tuPvX{jgf_~-z@(46U4JP=mLl;nE= zv}XiWQ10#|*h-AzG^8@Q}DAe=+bSips`}!XyoPb8j?{F6}x_GHcskY1ca%Nc1+9 zhtX4vCIg(98AXpcK#V*WbsT%OXuEk;ngOkeV+f=1sK}`HFK91JfW5VA1mHL#8>7su z23|uu&I?C|piS720}f4dPCQk8c2j2qAR=TBj#ydS0P|wXhKdzy9zG|)C&6b>ma!n3 z;dv+iZsv8nRAig!)Galkcn7kNCTR=ifAtlICfNrm7ERrO2;NoXa*PDvgZ)p z@!pqM&9Z*P#uPnC9^U0^Fi}X75k(nxB>u*B(|po<@13>1YOKaO?1sg4r#-9?*8by> z6m;p-l52eXvL(XB?WG04E9p>tsJo}5d}Z-HUAp+pH{P#)sXcQaDkhj@xcE>c_59hn z@kB-vNGJO+G%4EhS$9dB^p-a&NIn5(g(9P7IeBJ_5@qizVx6iE75qRf9;LZFJ90jo z77DQ@xp7Ui{{>YRed3fSG7+{zyzoI)m4vSf@sM&eiX|CYjBEl>p1=~;h<1Qhop(y( zEA`f%50I2KUwu9UtHXnkvs*!~Lj^B(jiU%Xyl=zJzmepyNwW5pklZP?b`FCx)uB(R zSSGWvb5_9?B)+{)jE~8kixsHbg2d~IFiSggWNpK=&rGIb#xr;2(dUt%hB|dsq(ekZ zT(QERDLO)#?SrDhmt!wTD+c5R@>uqQ|JzB$=CF^?A;G|W5x~Isf%$` zU{yL;*br8vQWzBhEdf2!E}3(+RY7}U$#iASwgQkZl>a#}-4vWs{-kH|R{U8gRIuRU z@dK8suHUKT`}IWojKE3zOpedf$K#Cy6IhYc_hFsM>;iK`Nn95~JUn!4vv0e)U~+BK zw~=YzT&iGKk?>eGd6uE;rk&J=p#^`k03sCPvSLtMxbFyC@!qa(9=%<|jK5jv{!|}Q z^{CXX&|gy1Y1CAU-O94JY}Kf&(ZLgCIuEmFVyRN{27Q;}KHlQgH@D6d8PDj%2jLm7 zS})3GxJfZ+jG>RGn>BY->vp7Z#U|xVpc>9yXQs52=(%;y(s1~((h!8@>#SAi0%~o( zWZqNYU7bfL;?s}_cSbCDVTXw<(5zONosg_`SULJmGatrnX*XE{YqQ5TAs=BlG&Evm zD~$9yRK{F&OS;NEUZ{}$mnvY-c>m0`vJvq|9wKi-WgMd@sC7fz^AKAD>2_kA^f}wp z5Tyda5m9zz>AV^h`Oc1gSjjV*0G8%>1>KiF5)jNmbZQw9goM|9@(Ar%S)hm@^jANeHWt31j%v9Qb6R1MG zeGM8`i|imnKh@=o+z-(Ov!ZnDF}l64_R|tn!xtC}i2cETCR2$m%`y-808n(YUro~Y zDozqPLU+=a5;VGM7s^? zbQn^by#;u=#8NL*QJ%fVW0&e4t#chRuz7>DtoWn09I5F_hWrC> z@ZKMuf!OKt?(nz481zy`%O-p9{8p)-^T{nzC1HOIFsZT ztR@mB8j|gJtrz$ZXPufyo+HIHXvEZWP^|K@+6He&^MrqxrD{j_gu%(9+p%O6B%**{ zl7@XD@=HFHF~L_w1yJa8c(w6YOE0=eF}UYx_Bw*Fvzb|N=HWpsa_4Lou48j@F^mU4 zPJHy8eD#OI7i$yTEzWp+bH1sZk5Jy~8wzI`4$+>Y5e9fNT96Tg5ZWZ#m>+Xx1br3W zxsv{n{CgQVOl2?Tg#ZIv{sIOj`ST!blJUH8hBNJ((@wVm^I& z`AqV?2f}i9Fd!}|FosvvvmmaN7g?jNs<5K4q;NXHUPdd-E=;`Lc{<_JQ>?#k?q`iB zUpC+&6fpc7Spwd`p)cFzTFxy#c>UG7RN0ajIa!2>Zoh<946^+O{J{ z58J84sUzv362cqS)U0}=ap>gR7(z>i!6lU3c~h&`kCCS1;gCGPvn`ioc5C5u(VdMbc5 zZ36;3=!4fgBTSJ5%WTdfC8Xq7oC|1=t+NhRRFRwS_f<+PZn_EH+G>+(CkwJJ5Mr@r z7WUu}Egxu#(EP@Mezg@ZeKnn&o5hd@51((Au-w4R4q0L@S+(S4K3UOahgm2KwMnT| zNG!hz@}sz`Ejw1!zvn@JfOKA3=Ta{^f9RF;eo7s7xkvX(INwS;gwkQqoYJghoCc5n zQ1y%u@XqP;4*`S(j|vWFms!M0>gUt(c?x5{PAdJ|!Gv%uKSyA|z``+rLLm|W8&Aw5 zEdO3ppbiyeSSVPaW@$!(sS65t^lTGZK~b16fqYEUy0M2mG#A@O`r4PvAz8hvEyGz( zO`m$$b?-n~bkVLw!@7dU!Cbq@+ip)F@B%}e|h015h6XnB~JeJ1JA8)-~|pq?d3%ilY94Uj2FLaA^-ax0RIQ#S?-0h z(o21ymLdyPxvI!U`#8Xc;5Z@#7_yccnr~NYb?&Yt>O#1MW_i_knYfIm7ft=JtUX|P zRX;q;&bDol_U1q3?%GL}2?!T%uNB!npQwA|7dJr5l)^T;RUd4`jVzvY;?PQUjB4}4 zfW{@8Roz_v=FRD*FIV&eNcrg(-t1J(afBbaEC_NsvmFXxF|oEEr|RcGi1T>+9bz8W z1pRz%;&ffMx7cLxaohtX-@U+$)GD_t>gRN4CYj%M63yrBHEoNF3Hzw+bhnHpKc9=w zSF{1sBnCGi{#KQig1cxN{0z=IxQ(vu0kl#`>(Stu+cew^7^pe~=&iAKUL`K3*>^y6 zp5KF(>NeHkZ1B7ieVrgGSD!Pko-U;HRT*YAdu@p-C0#w@k0Cy17={6z5RWSE-H>yTAB+tEnZIlhMV%G`ZaB}9Esd%RwLtSPeogUL=fTF8ST}0f$k)cXCg1HUq+_j zc(vX&tCyE}-K;m~iI$r5mzJ&ZlW%WMRu_SP69RC#%tELXiE&}iuByUJ9KSOT=bsUV(`-@(gVqTEd`7_ zHr&W&KXZ9pkMaQOSc8pI3lz;eZ=_*#Y5hEKjquYy6#HE~B?s=|4f~?u{YUyw*E40? zpqH#AI|>y6r!76EuS|Q-=pT8z@t46ud!lhS?{_M{SUcZmJSF-iy6Ecs$%bl@6C*A- zA6Fp@J1TZL{)DEkKyel=;l<&v09%O3a|f5qzj{N~N_(pH>wWuU_eW!3=gXqW&x&32 zZM3#0$S3Q-ILekd!jdH@$Ek^P5eS6|E7FG&945a&K*xSJt0nv5x)npIE$%|uf&ks%z3Uh${( zDTo$aIIm_Hpx)BHeoAig&s)O^Nctvid5^4&r)f^>H37NhpLk&Kp3Zy4cZNjx2xC@f zr4KC-fHXn{WUo;W9*v&}AcXx2CrPTZKL#J8|N`R+fc%FYCTVr|x;#h^Y| z9x+?QVki23GaD*9{NL84`?^;WW!o-jDPsDbV4i7caLj690*rjt zjC+2fM5GMF1zB$?v2K!O-i!pdrpTXD75lsN1Nt2k%{zX8zZYQfD3Q2VyEf{m^BrPvm~_?cii$Pcc=A4PYI%NYf1lg$#X z_9TqmhkHO%pdQy2d@>=~6|wb*gsDF&CLU}F=Z~mnBENV#P{SjjjPDWRjg1PgvqBzs zG&MW*s={ZC%?V|9MAn+jyBiv|s!}A80^G&JF*;-oWuPM_<~5hHwXTj5qbiA@D*+!% z>vgh3Qa!P|_p3aD-FluTk=|~t5EJYmU>seH4p4QJ4mho4joQ@Akw0Cu zg(j!B9C@`K>3VvMD(;nsTyl7aa4^d-_$i@fdHIX;EMH`ECP!&4x;$y4g|hZ~0hD${ zo&kh1ir8kCqcV$TI;TF>9eFF7zdi^#-*mYiUu{VW=G^c}o&sh<6^k7F&3GZSu;Ti@ zZDIIin%|;n>Phr11)0~{yb)xUs<@oL171z6neu}3l3Z5#!+B*#-lRe71>fxOV-u-J z%teDrM7kJ0dfc$>bl^FQu$rFl0SXZ{2aCTyDU@?i2HY^ABM`L74NI!JrRxD$t7Ree~2{Ii4_|Xg8|gKCXGXqBj9q&hBXq1(?r981_RVN$FHeXeu3FFKphDsUB246yYI4HU>GP4(sNyy^y=kWS_z4rwH}P1m<) ztUBeps7tNC^0bwW;rB&CX=j7s)f~gMj1gmv7B67JO81xr&nb0yTJ~^jLSy0=o-xQi z2rhBW{NU_Mndm^;N;|cIpH_TfBcgYoVE=yLtBS%AmHpjOK12V1FP3@HL;wS&1tZLn z&l%2+>I>66(jHcvFT9S3F8Huh}b2fRB$iq`VL;ES5u!L6ry~JLOU(9eP@dg#_)CI19lL z2lUXo8?!II;@CyA}ha3f;>b2`MEyN{s`DR=0WE6@Ziqpy4R>4;E8~zIrr4 zje`9|J3|84YyGyWq-#zMq z-$h}ggr>w)Gak4`H~9@H+%gu0Jv@quUzC!xC0DFspk|A~02PM_ZsI*0p74jN0NZ^U zq_`k9?h7YNIf!YoC?!17^v^&?BFNBk-sBs*HYH-lD*{f(F)(V%pGBx+ILyQW4$yGJ zlxfZ}En-4kN4O5c2eE_;ZJ2r3`~t!%aWfySN z+E3C$^pLMuH*zCCY&ynvGyw{CA%F;D+;qCDTdgi5mr@m)-viG0mF=a7DvbCIdpQ)b zgKqBnClRDxRcpWBPY3t}w@WnL^$N`Gb?!V_1x|I!^T3Ue%!kNEeZbF8f}gg1B?~}aZyr*cP9Xba zvMApthQy@;Y4P#x7;d#45h1yMvt7Z1_UiuFjb-u--C($9novJ0K36GCzt^35=(-#r zG}w&9(3fa0V)~f)DR8!C`&^ctW5Z8a8Z$?rTIyl(1>`&w=&H*oAW@)f86RfZa574d z_EnbCPW~ns?~?wjq(6XUPDzBJEamPSO6(NrkU5KJJ>pSW*ri0?I|awrK`*#M@O$`I zbS$=#Ug6i-y=ajdjrwTn<-N!~)*9uUJ-T6t909~86^R430&x!E6hE;`B32k>k78=J zMXx^ssxZ=*&^1r>h2=8PEfL&$=kpBiuF-+^Usg6a4%&p5Nsl-w{Ju}qqw!7<*3jP3 z1I2Ps;ToX!yCtyCUL5}IyA%>ts_lP$xBBl=%moZgp#!ERq62J{7L;-Q6<6j|cySL3 zCJ`dkG>wwMgOtS`B^yn_fq3XbDRYxaHI#NzfABs~dtRVoD8gnwX!d=Up{X-5fz>D7 z{5MBksZT3Q@ws5Kp7i9gJb1x>SOUD@5Lm^(jTh-9)qOLTkc_>&-I~_?3#jOld1U zi}%LKFaqC#iw=Nt%N6<78BPUKUUHt?(!B3`5X6V!lxfgtwO{=mX5l1=9@TF#VKI71 z1e0=+ymef^hZlIkLW4EJ(%oS9(jyabRB^%46lOuVUZUB`5L>4J;yE-H#LaQ=e$5o5 z;VR!grkVXczfx#Y5n++5mBE4rQ16(cM^7ZOVT}n1N`?g;H`w68j{c1l! zMtA0w(JCMgNr%(7asQ>{KrhhE#C;?uMua9!INg}8#+oqo2hIEQ!>3z)oeN@Nx2{w$ zp%C_BM;Km+h$T@tg7paQ;-qlzBV#^JSpD=%ivmyRH9Gr;`jcpLYR_}unf0^jwsxLn zX9uM1Xqa?L+KSyT=`RJQ#?sXWyXPMc_y~_4IO+<%kG&$8kn{p=S9yoBbu9 z$c^%WP~vD2lHb;%AxcWzX`<9KMy4S2LrKkh|r%%SK2AI9+_K1r-d(HK7NXm&JDu+%8&6Vp%>lw^5Sx` z&F6A0a56o4BP8SxUbeqRT9cPd^`j(FL?_IJR((D#yx5ow3CYZ=V*Xo+qgIZ=yyJHe zWEl5zCSrTDz(=AUvPULh+5B|F-X-0*&nCR(B&pG))4gq+S?^L{C6m^Ug~HlUjM;R> zR;%i!)ji}h<%V0-{qB5oZNG=%fF>Q*<0?R8M;VFFjK=qTW^CeBKaLn!oPHHlg@v`D>!)n_BZHiI+`8vp_`P8 zh%?6Jb;eCRPK^78Xku7y=~?vyj~)?Yt2p;&Ls9I7H^)e01WBHyE-LOKZT?qszBBDP z;_&Ai0iRC+G3#U&K#0wILW0M>Fq7yES@b%*pO0_T4EMsNz4-ZI+^dse6MF8-Baa%( zs-*mQ<{*s!y$$hw8CM~BSjJFMF@3pcJa#sdpx83AfV*1f9@nYSHzI_`1J*q+?+1KJ z-ZM|gmj#y5GMWjath-laM2t3Q8l@KFabT>;;ewsGonRR*K%1qPJW-C=co(6>UvxuI zQZ_6&*`kS%>>UgE$r(0n>&v&tPHIzcJS29r80*RWidm3@UG2smlx0-wt&H1Q4L-zzijyWJrGXqc`7=rB9e&ATf!YL3v(FCJAD zhNUG-qM}m3XX#HkwW9&Dns&;$w+;fJ6u0?Tqj99!S#sVBV;owreim>LyKl$8Zu{(X zc{P6T_4|XE7vhEhH>p?mVDi<$q(3N7qMM(yzNl4Zohn5k85g=GxpKfROuMIU#z?(O zY>Zh|t;Tm7U`;IjS~(*ARrryiQoeOiU&JrJ z87;aC#(S;_#P+{&R*ENe5SFnViQk1%h;F{~W$yd>xxh7Nal=zr%JME#c5}^(W;1cR^SKC#p!eB0SXTO({8a#ZjmKzeQvdEwnlUMGnl8*POdK7 zHD^${)^m-zOj09o-~?uS==c=?@V`_L?^#S=0o=zgU+#R-DFs6{aw1`?-J;y#tnAR$ z(8h>1$zn0uHB22-Pt6iR0`oD8$Y?X}kq)zpF^99Fw+NFGZ;Z^V9}{QcyhEz%IcHRB z6l0y$Ke$>Mx4`vTVh_O0t%SnD(FDV#60<UddcqI0J zvepb(mO(IoHw&GAGXbpsBm^bq&=`KI?KsRUV}2;oVj{ToZK|_la1kuqRf2# zvy@ft0%ydAF~4ixXx;>UWVeh+|6t_v+bLz4yB>#zY}PC1S9&K#tfqgG7FY82z>1}! z=xqtdW+kGF?YKeroVW(vYLDjEBphm#&ToVaX#1XZ+LoW5svSZl)fwIZa-!w-UPR-v z42$@Athp57beOu}W#BmGzgg_V(g$XVHrC0}P`x2-m%2nv(ss6G;z zboP4bA>Xx`A7DMlk3`2Sdd!(DlalC3eS_=x*MYc>L?|Y^;WT33Hzgdn> z$?VIe3>Q_WAKqc+K5*o+=j5T63dA0?I;NW8(F&Fu4>j==hW-9V(kM>$8|U9E)S<}| zH83_O1nzTpcx51#fUBbsKerkJKD4+A#{wM;Y?$tE;U^;i!Bc&y*^vI88wiA?NCXS! z|B5p9BMD42;1{d7dh!=$*syR0o$^s)lt@3J337H6$s_GjP zyGp+;LED?F$8Eh09|xZeZyUX{-lz2RNqJQ#iglE2DbC+}kwoR9K z>HQGAoLh&oIre=!{>r&)J+uC>i?2SlCXbSN%5Te3X`b(bIH$g3wF%o2_}{anEn>4*E*1qM6TCfLh`lQ{D`%wW85cuDZ52)5wptE(o3LiLM zJsY)8oU>bhVew{mEsabS!2OvkXdJ2*vAE~IH>-x^VD z;>JUR?A#LL6xpnY$yH)oSrls6ek?~hPQs4>f^K&e=`$l}cMP+8?D-bj#>?KYiR!#Uk zLb$O*1f4CSwa9Fn5YQ7<%hHSE_$zH}W&!I4=8NMA(fp$mxPAVyt~M;$_12H;Se5vI z7WTzurk#ck_p9}zRCeZ9EqgYP3=M-@qcS?{W}VJT%}ggtEW=TDIurWND!#EF>iBNm zYj7Ex!$x|mF&+~2priE0=*wI(woOelHtjZ6bh}FH=nMw3$_gILD%ndrGiKYhaYlWJ z94K=d%ry;?O}l1_$)Q1lI!KP3J*G(jW{Y;VO68h*PXHzj3c-3qa3UQ?lOX;evvw|v zf+%f8N)Ap;x}F&Jw`&7TM3@7)G=0kAi?mI*L~J=ugl7B>-WJ`tW>Hubdh#iA%WOQP z@teUszHQ7MNCEJ3}o53@<~T zhh;V{0V=kN4nAPw(IHZJQBpEMhsSo^*vsWk7#boFJrT1K3FYvhDM=(I3&Kz{2a*^ zT?en?=cXDQJCkm)zTjjAplzxF>yzml%=)lc=ru+?Tiu&mqLhY_(3|9^BHA=*Nmyr| z!Na1*O@GK`dr$yDn~SB>r|NX)<}Qs`(F&P-E>sH-N%xVU({!2(qPF0L!imffsK$3h;{ ztR3{0hzDz|(w*TF*3D%Us3c|0IC_@beio%|A`jGsLE^0}_zZ>$!|9oiXEQ?Ow9j`+ zgWzG+wXtj8GoKfJ#!|AM9~UfgnK+F9-Ru|fHa(&cd2VHTML7Qx;f1b_U+nO2#GaJe z1<&68+@lMm55gS)Sk^=wL$JdkWJGWje6Y|A7mEfWEqnJlwhq?;Zduu?=j;B|5%kUg z3}VmEUZY=jeh!XS@x29q4rQbB&j=%w`U$==&-R+$J2PB%wt3?OJzjCAXz z${j)S59-a?w18LyZB(bIJ5Cc&-CxRO^()<};pvsfN>17Hu(JE(2cpq%o~Ay~2ggT& z=k8e`2@Wd(tTunlDz&fd9_UP{l}7aYp*vll)t~Lf^fj`q@1DFs2mgNcf=#dKdVqkS z)ztrnfG9|2#XXD{%i*tb+8g+lvRV>yy(OItv(tcxyGkvT+nUMeVu-C|#2gdm$B;QJ z?CiY3X3$qs+h+ABY^KQcUaMcN6a?1ilaAczOq_bUfGBb+8-*$)YN-sn4DHRB;b;%2 zgR7yxK|^(XSA?yK+X?92fm-W78K#4e@&w^y_1x&lZa7?015RwXVFlS&=C~V?(3#Ph z8+-NUA=-$yv<>QwW|BwL&{bEyvER8~kW@@X$4ZKQINc022q1R43Dmly7&0ehk^F&Z zU20)507`x2X`&>{(UV{(u?FrfxdF%ht=H^8tEbXlDI}OErF%&h4^Kzl(=n5_*Q|HP ze#{s4)Z)EezvDuw*RwMsRi^i@v$&z^I1v=MC#NpQys8=AG7TLe?^y;waL2JlKK8gk zEgr^Y61?TXZbzM~W4h2+$c{c?tUtT#HAN4ufa1bW_Rz{x_T|^%`1C6fO-NXeEV3U? zPH__{ymQm}^E(P|ixv8uD%}woo5$(s3)$|GV~?FN?GC_4Ln zSe2t*mq92kVge2vm-v7T%rX7=A!kZ7z`usGd~(`7N}#k)5fVXTzTGj0JZ-%ov1a;F zBvCI78R_nj%!%vA>7X}(t%$<#5g$eeg3Kf5-n?agu$A%Tx2+9TxPaJ?^!Hcnpb8kIDF>56L=I#Sji0FnTcPp{%TUc#PnQB{c7+iPta}T-bVl)3t!KTfd3rrEo6Gr-r%;+a%7Beb+hl|-hv&7N>k~E0d64bDhuIU zbI_TG&67|`yE{+GB37kP7E)O(Y_bc>oF~TP7e~->OVOHa02YNs7KEWMN~Sx?R&60(R=&E zycejkFvUBN`?Lb=&BGVZPqXZ(m*D-b63S=KhfLS`jg{S;W@t3#u+_&ae_oDyM5`J4 z3lQqc)ERi?<~ju6RO=pnx@bGbq{=Uuu>v~?7sF|5b0L1I4@GN301EJHZ8vVN3dae> zCvo?V6r|PH=Q`oGIWh_s(UX7Ey_Lhqm}5_$=dX$KcZN?Vx?9K2++5`IgqO|U$l2pm z%!1?PZ0wd#GmK*aHH5_P>*@a_`AwD0vFV({rFcgjZHB$K`yMV%NLkXlj>%|ovHT5d zp%ka0o{gK`0zZuyy6M5+VT`R`hOa zYz7Jpt{6Jf^_t>31Ojqb59m;5olUX+&=t=#;v}jt*#*q;d9d-tiaFAJZD|GivQ9Zt z2Ak4+UgTH%c8gQlu9P>$l`mjdds0?RLUB7ImLx(-E4P(RfZUxDf)~h+M1T_4J;|Bo z2mRJC$-)&+(g*r)0qHt>Q;^n~&C9k7@XW~@qFXA#mbFBL4U`kg$e9gorFMGpKygMW zHZ2s2)jn%oneixMZ(pD#Tf4B3w~!ayy&RtX4!-P--fQ#9;|(o<^7EdrZjeRhkF{SG?Mv?PMjk zV6e8k9R#w3vXG1nQ2H?0I){iRPE6XHCw(R)N$-@IP@VbhVf6|@1l>(}Jze?x;>{Zx zSG0GS?IfbI*k0x}bod!#nUfZc%_0~G{fV2l zJ4B?5GZP_n3cgN7IwGc*X6(>}StoLG*_N^WWAjU@+q|4`6CU}ZQUMsbr5D*o$hLntXI@Cz<3^h#i;LU=JCSMHB#=>;w$N4o@KH? zw7Vf3bnzC&8D-N#6n~J?(ukE^Gt3^D93xRz5nHoqwswB}a^;ciOM2kI#3qxn8W6&A zu_IQX35`G(Rr=Zjqeb=0?1sK)dpE5Tv=@-Cf6mbJoGN55rBsc~lM+Hsmocdr?eF;a%a!i zJM(1L<5mBScxCRnJ$8G~;DK>RR_IXcbmR~3dx%ny9QrnLfeAOQk;DpE8l|ZV*>4ta zgf0&0-s~PR2Xg+MQY)}dYL?%8Ay3bXfT*R}N1A~xISx~?WS9mdD1Uqf!dXC+)VTv-KRp2(tX*lewzJI#ExR50J%d5^C9J}M3Z4b=)wxs>#CDdEFESpRQ zkENXeAZ7mk1WZG3nTgr_-jjUjK%l6Yk!d3G?IhJQAI4x&Nvkj2yxT|S)#i`^px@X~ z72i^VL&YwjlD6ncMO?B8HvQ-L5uE2zx99|-;SX$1Gjw0E>b&MdAk|kFiX!aUT5#e| zU)H}U+rQJl6FePD34ypr$T+? zFq@$>*=KpRr-0z)us0O22C1`F09=AyxS8n+_4oxObxK>smc(@=%3O_bqK|v56j>#; zO7zR`^5*h7hD5NO;e*9(IT3a4q{EG*`;Eqvcvb0d3v*(7Ah--^&MAK`u;0V}x|U5ny4X=gK!M70*37MAIA$El3EZ^8j-^DVN0D*RbfP#rr2b!-R ziayL93^C3KYy#8VEUOYT2W2v%zb%t-rIuJSgAq|JXG8$CLGC!0zQsZAT*x74bTwPt zNTtPj@8a<5N)&nT*e_bnU#WM(p13v`Vw1iQh$e^P_tPe-|A3mxm{35EbV+bV-+G-E{^5e6ZF9ET4l$EM^U> z|Fi`^wYzm-U%BDthPVr@&lGeM-%D5ug+DML>kW!vXsLb~giYL2BR` zKwA(Ccn>fK#0_x<2232r0$zdWAPB+#A(g=Kf#pM}KDTz~6&(5SeiQD?$b$ji3T`hwvfJaQ=g$z{UP+iw2Hh4g!YpA69XM2ZDg(A2Mfz3&KzOAF@sw@vjk7AnYhU z1ghLWqTEp=pt2k;&~TIv0$<^OMFJ3#>i>{l>O?@)F**n;oqt#z9ekk8Ulv0DAGT^t z2pk1?Ii?J54-^>Z2hRq2j~hbJSOPoE@POYfDS$QOs6groe26JqV4yuA@cV=a_zz(I z1V7<_`@+G%sQ%9Oe-DrYaL<9}?%9po;mAA}^W% z7&VPb_}@~J|7(RN{y*THxWCgmgG%_X-2K0XBuM%XxMqfm@PCq^rQl#-C4c9P`(HrX zpZ@{o#6bgVlF|Oh^8cntg=YVrW9q*E3F*+l&{=G#|2H|6_ZI+{@h`ycEEU1O(ggn+ z?f^(OCqei>apS$eSH=GCRr#N92mJTo&HazDjvV5D{^Wmy$^X||JPZC83=J$C!Uj^$ z<3o@)1EV{?0?p=`A%1uLB^m$mrKP_b@IK(}yg9^DKTv1E45ADK>|0(this::selectFromTree, this); + structureTree = new NodeTree<>(this::selectFromTree, this, SelectionMode.SINGLE); propertyEditor = new PropertyEditor<>(this); propertyEditor.prefHeightProperty().bind(root.heightProperty()); @@ -164,17 +166,18 @@ protected void createEditorAreaPane() { } /** - * Handle selected object from the structure tree. + * Handle selected objects from the structure tree. * - * @param object the selected object. + * @param objects the selected objects. */ @FxThread - private void selectFromTree(@Nullable final Object object) { + private void selectFromTree(@NotNull final Array objects) { setEditedShader(null); final GLSLCodeArea codeArea = getCodeArea(); codeArea.setEditable(false); + final Object object = objects.first(); Object parent = null; Object element; @@ -190,7 +193,7 @@ private void selectFromTree(@Nullable final Object object) { if (element instanceof SndShaderSource) { final SndShaderSource shaderSource = (SndShaderSource) element; - final String code = getGLSLCode(shaderSource.getShaderPath()); + final String code = getGlslCode(shaderSource.getShaderPath()); EXECUTOR_MANAGER.schedule(() -> { try { @@ -255,6 +258,8 @@ private void setEditedShader(@Nullable final String editedShader) { } /** + * Return true if need to ignore GLSL code changes. + * * @return true if need to ignore GLSL code changes. */ @FxThread @@ -263,6 +268,8 @@ private boolean isIgnoreCodeChanges() { } /** + * Set true if need to ignore GLSL code changes. + * * @param ignoreCodeChanges true if need to ignore GLSL code changes. */ @FxThread @@ -277,7 +284,10 @@ private void setIgnoreCodeChanges(final boolean ignoreCodeChanges) { */ @FxThread private void changeGLSLCode(@NotNull final String glslCode) { - if (isIgnoreCodeChanges()) return; + + if (isIgnoreCodeChanges()) { + return; + } final String editedShader = getEditedShader(); if (editedShader == null) { @@ -302,7 +312,7 @@ private void changeGLSLCode(@NotNull final String glslCode) { * @return the GLSL code. */ @FxThread - private @NotNull String getGLSLCode(@NotNull final String shaderPath) { + private @NotNull String getGlslCode(@NotNull final String shaderPath) { final ObjectDictionary glslChangedContent = getGlslChangedContent(); final String glslCode = glslChangedContent.get(shaderPath); @@ -445,7 +455,7 @@ public void notifyFxAddedChild(@NotNull final Object parent, @NotNull final Obje structureTree.notifyAdded(parent, added, index); if (needSelect) { - structureTree.select(added); + structureTree.selectSingle(added); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java index f48442e..63e1421 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java @@ -21,6 +21,8 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { /** + * Get the edited material definition. + * * @return the edited material definition. */ @FromAnyThread diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java similarity index 88% rename from src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java rename to src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java index 829748c..cfb80db 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java @@ -12,9 +12,9 @@ * * @author JavaSaBr */ -public class ShaderNodesEditor3DState extends BaseMaterialEditor3DPart { +public class ShaderNodesEditor3DPart extends BaseMaterialEditor3DPart { - public ShaderNodesEditor3DState(@NotNull final ShaderNodesFileEditor fileEditor) { + public ShaderNodesEditor3DPart(@NotNull final ShaderNodesFileEditor fileEditor) { super(fileEditor); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index b87c45f..08e05a3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -89,7 +89,7 @@ * @author JavaSaBr */ public class ShaderNodesFileEditor extends - BaseMaterialFileEditor implements + BaseMaterialFileEditor implements ShaderNodesChangeConsumer { @NotNull @@ -185,8 +185,8 @@ public class ShaderNodesFileEditor extends @Override @FxThread - protected @NotNull ShaderNodesEditor3DState create3DEditorPart() { - return new ShaderNodesEditor3DState(this); + protected @NotNull ShaderNodesEditor3DPart create3DEditorPart() { + return new ShaderNodesEditor3DPart(this); } @Override @@ -240,7 +240,7 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { setMaterialDef(materialDef); - final ShaderNodesEditor3DState editor3DPart = getEditor3DPart(); + final ShaderNodesEditor3DPart editor3DPart = getEditor3DPart(); editor3DPart.updateMaterial(EditorUtil.getDefaultMaterial()); editor3DPart.changeMode(ModelType.BOX); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java index 6982a7c..3c337f6 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java @@ -210,7 +210,8 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve */ @FxThread public @Nullable ShaderNodeState getState(@NotNull final ShaderNode shaderNode) { - return shaderNodeStates.stream().filter(variableState -> variableState.getName().equals(shaderNode.getName())) + return shaderNodeStates.stream() + .filter(varState -> varState.getName().equals(shaderNode.getName())) .findAny().orElse(null); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java index a2bf433..65a142d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java @@ -56,8 +56,7 @@ public class ShaderNodesTreeNodeFactory implements TreeNodeFactory { } @Override - @FxThread - public int getOrder() { + public int getPriority() { return 5; } } From 53fcf66d8373cdd705bf45f023c666c0079e710b Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Thu, 22 Feb 2018 09:37:43 +0300 Subject: [PATCH 10/25] upgraded for 1.7.0 --- README.md | 4 +- build.gradle | 2 +- .../shader/nodes/ShaderNodesEditorPlugin.java | 26 +-- .../model/shader/node/ShaderNodesProject.java | 10 +- .../model/shader/node/definition/SndList.java | 4 +- ...nCSSClasses.java => PluginCssClasses.java} | 2 +- .../ui/component/SndDocumentationArea.java | 6 +- .../ShaderNodeDefinitionsFileCreator.java | 6 +- .../ShaderNodeDefinitionFileEditor.java | 76 ++++---- .../editor/ShaderNodesChangeConsumer.java | 46 ++--- ...tate.java => ShaderNodesEditor3DPart.java} | 15 +- .../editor/ShaderNodesFileEditor.java | 170 +++++++++--------- .../editor/state/ShaderNodeState.java | 14 +- .../editor/state/ShaderNodeVariableState.java | 18 +- .../editor/state/ShaderNodesEditorState.java | 10 +- .../editor/state/TechniqueDefState.java | 30 ++-- .../preview/CodePreviewComponent.java | 10 +- .../MaterialDefCodePreviewComponent.java | 6 +- .../FragmentShaderCodePreviewComponent.java | 4 +- .../shader/ShaderCodePreviewComponent.java | 28 +-- .../VertexShaderCodePreviewComponent.java | 4 +- .../shader/nodes/ShaderNodeElement.java | 54 +++--- .../shader/nodes/ShaderNodesContainer.java | 100 +++++------ .../shader/nodes/action/ShaderNodeAction.java | 14 +- .../add/AddAttributeShaderNodeAction.java | 8 +- .../add/AddMaterialParamShaderNodeAction.java | 12 +- .../AddMaterialTextureShaderNodeAction.java | 8 +- .../action/add/AddNodeShaderNodeAction.java | 24 ++- ...TechniqueDefParameterShaderNodeAction.java | 10 +- .../add/AddWorldParamShaderNodeAction.java | 8 +- .../RemoveAttributeShaderNodeAction.java | 6 +- .../RemoveMaterialParamShaderNodeAction.java | 6 +- .../RemoveRelationShaderNodeAction.java | 6 +- .../action/remove/RemoveShaderNodeAction.java | 6 +- .../RemoveWorldParamShaderNodeAction.java | 6 +- .../nodes/global/GlobalShaderNodeElement.java | 10 +- .../global/InputGlobalShaderNodeElement.java | 14 +- .../global/OutputGlobalShaderNodeElement.java | 12 +- .../component/shader/nodes/line/TempLine.java | 8 +- .../shader/nodes/line/VariableLine.java | 12 +- .../main/AttributeShaderNodeElement.java | 8 +- .../nodes/main/FragmentShaderNodeElement.java | 4 +- .../nodes/main/MainShaderNodeElement.java | 14 +- .../nodes/main/MaterialShaderNodeElement.java | 21 ++- .../main/OutputVariableShaderNodeElement.java | 6 +- .../nodes/main/VariableShaderNodeElement.java | 12 +- .../nodes/main/VertexShaderNodeElement.java | 4 +- .../nodes/main/WorldShaderNodeElement.java | 8 +- .../operation/ChangeLightModeOperation.java | 20 +-- .../nodes/operation/ShaderNodeOperation.java | 36 ++-- .../operation/add/AddAttributeOperation.java | 28 +-- .../add/AddMaterialParameterOperation.java | 28 +-- .../operation/add/AddShaderNodeOperation.java | 28 +-- .../operation/add/AddTechniqueOperation.java | 28 +-- .../add/AddWorldParameterOperation.java | 28 +-- .../AttachAttributeToShaderNodeOperation.java | 14 +- .../AttachGlobalToShaderNodeOperation.java | 14 +- .../attach/AttachShaderNodeOperation.java | 16 +- .../AttachUniformToShaderNodeOperation.java | 14 +- .../AttachVarToGlobalNodeOperation.java | 14 +- .../AttachVarToShaderNodeOperation.java | 14 +- .../detach/DetachShaderNodeOperation.java | 30 ++-- .../InputDetachShaderNodeOperation.java | 4 +- .../OutputDetachShaderNodeOperation.java | 4 +- .../RemoveAttributeVariableOperation.java | 28 +-- ...oveMaterialParameterVariableOperation.java | 28 +-- .../remove/RemoveShaderNodeOperation.java | 28 +-- .../RemoveUniformVariableOperation.java | 14 +- .../remove/RemoveVariableOperation.java | 14 +- ...RemoveWorldParameterVariableOperation.java | 28 +-- .../EditableMaterialShaderNodeParameter.java | 10 +- .../parameter/InputShaderNodeParameter.java | 8 +- .../parameter/OutputShaderNodeParameter.java | 8 +- .../nodes/parameter/ShaderNodeParameter.java | 20 +-- .../parameter/socket/InputSocketElement.java | 10 +- .../parameter/socket/OutputSocketElement.java | 10 +- .../nodes/parameter/socket/SocketElement.java | 10 +- .../tooltip/SndDocumentationTooltip.java | 23 ++- .../ui/control/tree/action/AddSndAction.java | 12 +- .../action/AddSndInputParameterAction.java | 6 +- .../action/AddSndOutputParameterAction.java | 6 +- .../tree/action/AddSndParameterAction.java | 28 +-- .../tree/action/AddSndShaderSourceAction.java | 12 +- .../control/tree/action/DeleteSndAction.java | 8 +- .../action/DeleteSndShaderSourceAction.java | 8 +- .../tree/action/DeleteSndarameterAction.java | 8 +- .../action/EditSndDocumentationAction.java | 8 +- .../factory/ShaderNodesTreeNodeFactory.java | 10 +- .../node/PreviewMaterialSettingsTreeNode.java | 2 +- .../definition/SndDocumentationTreeNode.java | 6 +- .../tree/node/definition/SndListTreeNode.java | 10 +- .../node/definition/SndParameterTreeNode.java | 10 +- .../definition/SndParametersTreeNode.java | 10 +- .../definition/SndShaderSourceTreeNode.java | 6 +- .../definition/SndShaderSourcesTreeNode.java | 12 +- .../tree/node/definition/SndTreeNode.java | 14 +- .../tree/operation/AddSndOperation.java | 10 +- .../operation/AddSndParameterOperation.java | 10 +- .../AddSndShaderSourceOperation.java | 10 +- .../ChangeSndDocumentationOperation.java | 10 +- .../tree/operation/DeleteSndOperation.java | 10 +- .../DeleteSndParameterOperation.java | 10 +- .../DeleteSndShaderSourceOperation.java | 10 +- .../tree/operation/RenameSndOperation.java | 10 +- .../RenameSndParameterOperation.java | 10 +- .../property/ShaderNodesPropertyBuilder.java | 16 +- .../ui/dialog/EditSndDocumentationDialog.java | 14 +- .../nodes/ui/preview/SndFilePreview.java | 26 ++- .../ui/preview/SndFilePreviewFactory.java | 4 +- .../shader/nodes/util/ShaderNodeUtils.java | 4 +- 110 files changed, 897 insertions(+), 884 deletions(-) rename src/main/java/com/ss/editor/shader/nodes/ui/{PluginCSSClasses.java => PluginCssClasses.java} (97%) rename src/main/java/com/ss/editor/shader/nodes/ui/component/editor/{ShaderNodesEditor3DState.java => ShaderNodesEditor3DPart.java} (72%) diff --git a/README.md b/README.md index 8600a2b..9e8a2a9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -## Shader Nodes Plugin 1.1.0 +## Shader Nodes Plugin 1.1.1 It's a plugin for jMonkeyBuilder to support working with shader modes. -#### It requires jMonkeyBuilder 1.3.2 or higher. +#### It requires jMonkeyBuilder 1.7.0 or higher. Creating the shader nodes project file: diff --git a/build.gradle b/build.gradle index cc3ba41..e596342 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'idea' apply plugin: 'org.junit.platform.gradle.plugin' group = 'com.spaceshift' -version = '1.1.0' +version = '1.1.1' ext.artifactId = 'shader-nodes' diff --git a/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java b/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java index f5fb88f..8a23b19 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java +++ b/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java @@ -3,10 +3,9 @@ import com.jme3.asset.AssetManager; import com.jme3.shader.glsl.AstGlsl150ShaderGenerator; import com.jme3.shader.glsl.AstShaderGenerator; -import com.ss.editor.Editor; import com.ss.editor.FileExtensions; -import com.ss.editor.annotation.FXThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.FileIconManager; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.EditorPlugin; @@ -20,9 +19,10 @@ import com.ss.editor.ui.component.creator.FileCreatorRegistry; import com.ss.editor.ui.component.editor.EditorRegistry; import com.ss.editor.ui.control.property.builder.PropertyBuilderRegistry; -import com.ss.editor.ui.control.tree.node.TreeNodeFactoryRegistry; -import com.ss.editor.ui.css.CSSRegistry; +import com.ss.editor.ui.control.tree.node.factory.TreeNodeFactoryRegistry; +import com.ss.editor.ui.css.CssRegistry; import com.ss.editor.ui.preview.FilePreviewFactoryRegistry; +import com.ss.editor.util.EditorUtil; import com.ss.rlib.plugin.PluginContainer; import com.ss.rlib.plugin.PluginSystem; import com.ss.rlib.plugin.annotation.PluginDescription; @@ -35,8 +35,8 @@ */ @PluginDescription( id = "com.ss.editor.shader.nodes", - version = "1.1.0", - minAppVersion = "1.3.2", + version = "1.1.1", + minAppVersion = "1.7.0", name = "Shader Nodes Tools", description = "The plugin with editors to work with shader node materials." ) @@ -50,17 +50,17 @@ public ShaderNodesEditorPlugin(@NotNull final PluginContainer pluginContainer) { } @Override - public void onAfterCreateJMEContext(@NotNull final PluginSystem pluginSystem) { - super.onAfterCreateJMEContext(pluginSystem); + public void onAfterCreateJmeContext(@NotNull final PluginSystem pluginSystem) { + super.onAfterCreateJmeContext(pluginSystem); System.setProperty(AstShaderGenerator.PROP_USE_CASE, "false"); - final AssetManager assetManager = Editor.getInstance().getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); assetManager.setShaderGenerator(new AstGlsl150ShaderGenerator(assetManager)); } - @FXThread + @FxThread @Override - public void onBeforeCreateJavaFXContext(@NotNull final PluginSystem pluginSystem) { - super.onBeforeCreateJavaFXContext(pluginSystem); + public void onBeforeCreateJavaFxContext(@NotNull final PluginSystem pluginSystem) { + super.onBeforeCreateJavaFxContext(pluginSystem); final ResourceManager resourceManager = ResourceManager.getInstance(); resourceManager.registerInterestedFileType(FileExtensions.JME_SHADER_NODE); resourceManager.registerInterestedFileType(FileExtensions.GLSL_LIB); @@ -68,7 +68,7 @@ public void onBeforeCreateJavaFXContext(@NotNull final PluginSystem pluginSystem @Override @FromAnyThread - public void register(@NotNull final CSSRegistry registry) { + public void register(@NotNull final CssRegistry registry) { super.register(registry); registry.register("com/ss/editor/shader/nodes/style.css", getClassLoader()); } diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java index 5df646d..066ddfd 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java @@ -6,7 +6,7 @@ import com.jme3.util.clone.Cloner; import com.jme3.util.clone.JmeCloneable; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.state.TechniqueDefState; import com.ss.editor.util.EditorUtil; import org.jetbrains.annotations.NotNull; @@ -108,7 +108,7 @@ public void setMaterialDefContent(@NotNull final String materialDefContent) { } @Override - @JMEThread + @JmeThread public ShaderNodesProject jmeClone() { try { return (ShaderNodesProject) super.clone(); @@ -118,13 +118,13 @@ public ShaderNodesProject jmeClone() { } @Override - @JMEThread + @JmeThread public void cloneFields(@NotNull final Cloner cloner, @NotNull final Object original) { matParams = cloner.clone(matParams); } @Override - @JMEThread + @JmeThread public void write(@NotNull final JmeExporter ex) throws IOException { final byte[] techStates = EditorUtil.serialize(techniqueDefStates); @@ -136,7 +136,7 @@ public void write(@NotNull final JmeExporter ex) throws IOException { } @Override - @JMEThread + @JmeThread public void read(@NotNull final JmeImporter im) throws IOException { final InputCapsule in = im.getCapsule(this); diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java index cdbd83a..b79684d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.model.shader.node.definition; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -28,7 +28,7 @@ public SndList(@NotNull final List definitions) { * * @return the list of definitions. */ - @FXThread + @FxThread public @NotNull List getDefinitions() { return definitions; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/PluginCSSClasses.java b/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java similarity index 97% rename from src/main/java/com/ss/editor/shader/nodes/ui/PluginCSSClasses.java rename to src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java index 9427f02..fb76d8d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/PluginCSSClasses.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java @@ -7,7 +7,7 @@ * * @author JavaSaBr */ -public interface PluginCSSClasses { +public interface PluginCssClasses { @NotNull String SHADER_NODES_ROOT = "shader-nodes-root"; @NotNull String SHADER_NODE = "shader-node"; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/SndDocumentationArea.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/SndDocumentationArea.java index ef2fb39..e9a715c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/SndDocumentationArea.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/SndDocumentationArea.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.component; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.code.BaseCodeArea; import org.fxmisc.richtext.model.StyleSpans; import org.jetbrains.annotations.NotNull; @@ -32,13 +32,13 @@ public class SndDocumentationArea extends BaseCodeArea { ); @Override - @FXThread + @FxThread protected @NotNull String[][] getAvailableClasses() { return AVAILABLE_CLASSES; } @Override - @FXThread + @FxThread protected @NotNull StyleSpans> calculateStyleSpans(@NotNull final String text) { return computeHighlighting(PATTERN, text); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java index c461f02..37f78bf 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java @@ -9,7 +9,7 @@ import com.jme3.shader.Shader.ShaderType; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditablePropertyType; import com.ss.editor.plugin.api.file.creator.GenericFileCreator; @@ -82,7 +82,7 @@ public class ShaderNodeDefinitionsFileCreator extends GenericFileCreator { AVAILABLE_TYPES.add(ShaderType.Vertex.name()); AVAILABLE_TYPES.add(ShaderType.Fragment.name()); - final Renderer renderer = EDITOR.getRenderer(); + final Renderer renderer = EditorUtil.getRenderer(); final EnumSet caps = renderer.getCaps(); caps.stream().filter(cap -> cap.name().startsWith("GLSL")) @@ -124,7 +124,7 @@ public class ShaderNodeDefinitionsFileCreator extends GenericFileCreator { } @Override - @FXThread + @FxThread protected void processOk() { super.hide(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java index 4dfbba4..f05ddfa 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java @@ -8,7 +8,7 @@ import com.jme3.shader.glsl.parser.GlslParser; import com.ss.editor.FileExtensions; import com.ss.editor.annotation.BackgroundThread; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.model.undo.editor.ChangeConsumer; @@ -25,10 +25,12 @@ import com.ss.editor.ui.control.property.PropertyEditor; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.editor.ui.css.CSSClasses; +import com.ss.editor.ui.css.CssClasses; +import com.ss.editor.util.EditorUtil; import com.ss.rlib.ui.util.FXUtils; import com.ss.rlib.util.FileUtils; import com.ss.rlib.util.StringUtils; +import com.ss.rlib.util.array.Array; import com.ss.rlib.util.dictionary.DictionaryFactory; import com.ss.rlib.util.dictionary.ObjectDictionary; import javafx.scene.control.SplitPane; @@ -118,7 +120,7 @@ public ShaderNodeDefinitionFileEditor() { } @Override - @FXThread + @FxThread protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { super.createToolComponents(container, root); @@ -129,17 +131,17 @@ protected void createToolComponents(@NotNull final EditorToolComponent container container.addComponent(buildSplitComponent(structureTree, propertyEditor, root), PluginMessages.SND_EDITOR_TOOL_STRUCTURE); - FXUtils.addClassTo(structureTree.getTreeView(), CSSClasses.TRANSPARENT_TREE_VIEW); + FXUtils.addClassTo(structureTree.getTreeView(), CssClasses.TRANSPARENT_TREE_VIEW); } - @FXThread + @FxThread @Override protected void calcVSplitSize(@NotNull final SplitPane splitPane) { splitPane.setDividerPosition(0, 0.6); } @Override - @FXThread + @FxThread protected void createEditorAreaPane() { super.createEditorAreaPane(); @@ -157,23 +159,24 @@ protected void createEditorAreaPane() { * * @return the code area. */ - @FXThread + @FxThread private @NotNull GLSLCodeArea getCodeArea() { return notNull(codeArea); } /** - * Handle selected object from the structure tree. + * Handle selected objects from the structure tree. * - * @param object the selected object. + * @param objects the selected objects. */ - @FXThread - private void selectFromTree(@Nullable final Object object) { + @FxThread + private void selectFromTree(@Nullable final Array objects) { setEditedShader(null); final GLSLCodeArea codeArea = getCodeArea(); codeArea.setEditable(false); + final Object object = objects.first(); Object parent = null; Object element; @@ -218,7 +221,7 @@ private void selectFromTree(@Nullable final Object object) { * * @return the dictionary to store original GLSL code. */ - @FXThread + @FxThread private @NotNull ObjectDictionary getGlslOriginalContent() { return glslOriginalContent; } @@ -228,7 +231,7 @@ private void selectFromTree(@Nullable final Object object) { * * @return the dictionary to track changes of GLSL code. */ - @FXThread + @FxThread private @NotNull ObjectDictionary getGlslChangedContent() { return glslChangedContent; } @@ -238,7 +241,7 @@ private void selectFromTree(@Nullable final Object object) { * * @return the current edited shader. */ - @FXThread + @FxThread private @Nullable String getEditedShader() { return editedShader; } @@ -248,7 +251,7 @@ private void selectFromTree(@Nullable final Object object) { * * @param editedShader the current edited shader. */ - @FXThread + @FxThread private void setEditedShader(@Nullable final String editedShader) { this.editedShader = editedShader; } @@ -256,7 +259,7 @@ private void setEditedShader(@Nullable final String editedShader) { /** * @return true if need to ignore GLSL code changes. */ - @FXThread + @FxThread private boolean isIgnoreCodeChanges() { return ignoreCodeChanges; } @@ -264,7 +267,7 @@ private boolean isIgnoreCodeChanges() { /** * @param ignoreCodeChanges true if need to ignore GLSL code changes. */ - @FXThread + @FxThread private void setIgnoreCodeChanges(final boolean ignoreCodeChanges) { this.ignoreCodeChanges = ignoreCodeChanges; } @@ -274,9 +277,12 @@ private void setIgnoreCodeChanges(final boolean ignoreCodeChanges) { * * @param glslCode the new GLSL code. */ - @FXThread + @FxThread private void changeGLSLCode(@NotNull final String glslCode) { - if (isIgnoreCodeChanges()) return; + + if (isIgnoreCodeChanges()) { + return; + } final String editedShader = getEditedShader(); if (editedShader == null) { @@ -300,7 +306,7 @@ private void changeGLSLCode(@NotNull final String glslCode) { * @param shaderPath the shader path. * @return the GLSL code. */ - @FXThread + @FxThread private @NotNull String getGLSLCode(@NotNull final String shaderPath) { final ObjectDictionary glslChangedContent = getGlslChangedContent(); @@ -328,7 +334,7 @@ private void changeGLSLCode(@NotNull final String glslCode) { } @Override - @FXThread + @FxThread protected void doOpenFile(@NotNull final Path file) throws IOException { super.doOpenFile(file); @@ -337,7 +343,7 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(assetPath); key.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); definitionList = assetManager.loadAsset(key); @@ -395,7 +401,7 @@ protected void doSave(@NotNull final Path toStore) throws IOException { * * @return the structure tree. */ - @FXThread + @FxThread private @NotNull NodeTree getStructureTree() { return notNull(structureTree); } @@ -405,26 +411,26 @@ protected void doSave(@NotNull final Path toStore) throws IOException { * * @return the property editor. */ - @FXThread + @FxThread private @NotNull PropertyEditor getPropertyEditor() { return notNull(propertyEditor); } @Override - @FXThread + @FxThread protected boolean needToolbar() { return true; } @Override - @FXThread + @FxThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); FXUtils.addToPane(createSaveAction(), container); } @Override - @FXThread + @FxThread protected @Nullable Supplier getEditorStateFactory() { return ShaderNodeDefinitionEditorState::new; } @@ -436,29 +442,29 @@ protected void createToolbar(@NotNull final HBox container) { } @Override - @FXThread - public void notifyFXAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index, + @FxThread + public void notifyFxAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index, final boolean needSelect) { final NodeTree structureTree = getStructureTree(); structureTree.notifyAdded(parent, added, index); if (needSelect) { - structureTree.select(added); + structureTree.selectSingle(added); } } @Override - @FXThread - public void notifyFXRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { + @FxThread + public void notifyFxRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { getStructureTree().notifyRemoved(parent, removed); } @Override - @FXThread - public void notifyFXChangeProperty(@Nullable final Object parent, @NotNull final Object object, + @FxThread + public void notifyFxChangeProperty(@Nullable final Object parent, @NotNull final Object object, @NotNull final String propertyName) { - super.notifyFXChangeProperty(parent, object, propertyName); + super.notifyFxChangeProperty(parent, object, propertyName); final NodeTree structureTree = getStructureTree(); structureTree.notifyChanged(parent, object); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java index 8517081..f48442e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java @@ -9,7 +9,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param shaderNode the shader nodes. * @param mapping the variable mapping. */ - @FXThread + @FxThread void notifyAddedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping); /** @@ -49,7 +49,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param shaderNode the shader nodes. * @param mapping the variable mapping. */ - @FXThread + @FxThread void notifyRemovedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping); /** @@ -59,7 +59,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param oldMapping the old variable mapping. * @param newMapping the new variable mapping. */ - @FXThread + @FxThread void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping oldMapping, @NotNull final VariableMapping newMapping); @@ -69,7 +69,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param matParam the material parameter. * @param location the location. */ - @FXThread + @FxThread void notifyAddedMatParameter(@NotNull final MatParam matParam, @NotNull Vector2f location); /** @@ -77,7 +77,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * * @param matParam the material parameter. */ - @FXThread + @FxThread void notifyRemovedMatParameter(@NotNull final MatParam matParam); /** @@ -86,7 +86,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param variable the variable of the attribute. * @param location the location. */ - @FXThread + @FxThread void notifyAddedAttribute(@NotNull final ShaderNodeVariable variable, @NotNull Vector2f location); /** @@ -94,7 +94,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * * @param variable the variable of the attribute. */ - @FXThread + @FxThread void notifyRemovedAttribute(@NotNull final ShaderNodeVariable variable); /** @@ -103,7 +103,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param binding the binding. * @param location the location. */ - @FXThread + @FxThread void notifyAddedWorldParameter(@NotNull final UniformBinding binding, @NotNull Vector2f location); /** @@ -111,7 +111,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * * @param binding the binding. */ - @FXThread + @FxThread void notifyRemovedWorldParameter(@NotNull final UniformBinding binding); /** @@ -120,7 +120,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param shaderNode the shader nodes. * @param location the location. */ - @FXThread + @FxThread void notifyAddedShaderNode(@NotNull final ShaderNode shaderNode, @NotNull Vector2f location); /** @@ -128,7 +128,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * * @param shaderNode the shader nodes. */ - @FXThread + @FxThread void notifyRemovedRemovedShaderNode(@NotNull final ShaderNode shaderNode); /** @@ -138,7 +138,7 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param location the location. * @param width the width. */ - @FXThread + @FxThread void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location, final double width); @@ -149,7 +149,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param location the location. * @param width the width. */ - @FXThread + @FxThread void notifyChangeState(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location, final double width); /** @@ -159,7 +159,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param location the location. * @param width the width. */ - @FXThread + @FxThread void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vector2f location, final double width); /** @@ -168,7 +168,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param shaderNode the shader nodes. * @return the location or null. */ - @FXThread + @FxThread @Nullable Vector2f getLocation(@NotNull final ShaderNode shaderNode); /** @@ -177,7 +177,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param variable the shader nodes variable. * @return the location or null. */ - @FXThread + @FxThread @Nullable Vector2f getLocation(@NotNull final ShaderNodeVariable variable); /** @@ -186,7 +186,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param input true if it's input global nodes. * @return the location or null. */ - @FXThread + @FxThread @Nullable Vector2f getGlobalNodeLocation(final boolean input); /** @@ -195,7 +195,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param shaderNode the shader nodes. * @return the width or 0. */ - @FXThread + @FxThread double getWidth(@NotNull final ShaderNode shaderNode); /** @@ -204,7 +204,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param variable the shader nodes variable. * @return the width or null. */ - @FXThread + @FxThread double getWidth(@NotNull final ShaderNodeVariable variable); /** @@ -213,7 +213,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * @param input true if it's input global nodes. * @return the width or null. */ - @FXThread + @FxThread double getGlobalNodeWidth(final boolean input); /** @@ -221,7 +221,7 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * * @param techniqueDef the technique definition. */ - @FXThread + @FxThread void notifyAddedTechnique(@NotNull final TechniqueDef techniqueDef); /** @@ -229,6 +229,6 @@ void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull fina * * @param techniqueDef the technique definition. */ - @FXThread + @FxThread void notifyRemovedTechnique(@NotNull final TechniqueDef techniqueDef); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java similarity index 72% rename from src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java rename to src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java index 179b5fb..83e9444 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java @@ -2,8 +2,9 @@ import com.jme3.material.Material; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; -import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState; +import com.ss.editor.annotation.JmeThread; +import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DPart; +import com.ss.editor.util.EditorUtil; import org.jetbrains.annotations.NotNull; /** @@ -11,9 +12,9 @@ * * @author JavaSaBr */ -public class ShaderNodesEditor3DState extends BaseMaterialEditor3DState { +public class ShaderNodesEditor3DPart extends BaseMaterialEditor3DPart { - public ShaderNodesEditor3DState(@NotNull final ShaderNodesFileEditor fileEditor) { + public ShaderNodesEditor3DPart(@NotNull final ShaderNodesFileEditor fileEditor) { super(fileEditor); } @@ -25,7 +26,7 @@ public ShaderNodesEditor3DState(@NotNull final ShaderNodesFileEditor fileEditor) */ @FromAnyThread public void selectTechnique(@NotNull final Material material, @NotNull final String name) { - EXECUTOR_MANAGER.addJMETask(() -> selectTechniqueImpl(material, name)); + EXECUTOR_MANAGER.addJmeTask(() -> selectTechniqueImpl(material, name)); } /** @@ -34,9 +35,9 @@ public void selectTechnique(@NotNull final Material material, @NotNull final Str * @param material the material. * @param name the name. */ - @JMEThread + @JmeThread private void selectTechniqueImpl(@NotNull final Material material, @NotNull final String name) { - material.selectTechnique(name, EDITOR.getRenderManager()); + material.selectTechnique(name, EditorUtil.getRenderManager()); updateMaterialImpl(material); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index 4b59954..6934328 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -14,6 +14,7 @@ import com.jme3.material.plugin.export.materialdef.J3mdExporter; import com.jme3.material.plugins.J3MLoader; import com.jme3.math.Vector2f; +import com.jme3.renderer.RenderManager; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; @@ -21,11 +22,11 @@ import com.ss.editor.FileExtensions; import com.ss.editor.Messages; import com.ss.editor.annotation.BackgroundThread; -import com.ss.editor.annotation.FXThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; -import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DState.ModelType; +import com.ss.editor.plugin.api.editor.material.BaseMaterialEditor3DPart; import com.ss.editor.plugin.api.editor.material.BaseMaterialFileEditor; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.shader.nodes.PluginMessages; @@ -52,10 +53,10 @@ import com.ss.editor.ui.component.editor.state.EditorState; import com.ss.editor.ui.component.tab.EditorToolComponent; import com.ss.editor.ui.control.property.PropertyEditor; -import com.ss.editor.ui.css.CSSClasses; +import com.ss.editor.ui.css.CssClasses; import com.ss.editor.ui.dialog.asset.virtual.StringVirtualAssetEditorDialog; import com.ss.editor.ui.util.DynamicIconSupport; -import com.ss.editor.ui.util.UIUtils; +import com.ss.editor.ui.util.UiUtils; import com.ss.editor.util.EditorUtil; import com.ss.editor.util.MaterialUtils; import com.ss.rlib.ui.util.FXUtils; @@ -88,7 +89,7 @@ * @author JavaSaBr */ public class ShaderNodesFileEditor extends - BaseMaterialFileEditor implements + BaseMaterialFileEditor implements ShaderNodesChangeConsumer { @NotNull @@ -183,23 +184,23 @@ public class ShaderNodesFileEditor extends private boolean ignoreLightModeChanges; @Override - @FXThread - protected @NotNull ShaderNodesEditor3DState create3DEditorState() { - return new ShaderNodesEditor3DState(this); + @FxThread + protected @NotNull ShaderNodesEditor3DPart create3DEditorPart() { + return new ShaderNodesEditor3DPart(this); } @Override - @FXThread + @FxThread protected @Nullable Supplier getEditorStateFactory() { return ShaderNodesEditorState::new; } @Override - @FXThread + @FxThread protected void doOpenFile(@NotNull final Path file) throws IOException { super.doOpenFile(file); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final BinaryImporter importer = BinaryImporter.getInstance(); importer.setAssetManager(assetManager); @@ -238,18 +239,18 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { }); setMaterialDef(materialDef); - getEditor3DState().updateMaterial(EDITOR.getDefaultMaterial()); - final ShaderNodesEditor3DState editor3DState = getEditor3DState(); - editor3DState.changeMode(ModelType.BOX); + final ShaderNodesEditor3DPart editor3DPart = getEditor3DPart(); + editor3DPart.updateMaterial(EditorUtil.getDefaultMaterial()); + editor3DPart.changeMode(BaseMaterialEditor3DPart.ModelType.BOX); } @Override - @FXThread + @FxThread protected void loadState() { super.loadState(); - EXECUTOR_MANAGER.addFXTask(this::buildMaterial); + EXECUTOR_MANAGER.addFxTask(this::buildMaterial); final ShaderNodesEditorState editorState = getEditorState(); if (editorState == null) { @@ -298,7 +299,7 @@ protected void doSave(@NotNull final Path toStore) throws IOException { } @Override - @FXThread + @FxThread protected void createEditorAreaPane() { super.createEditorAreaPane(); @@ -316,21 +317,24 @@ protected void createEditorAreaPane() { }); FXUtils.addToPane(splitPanel, editorAreaPane); - FXUtils.addClassTo(splitPanel, CSSClasses.FILE_EDITOR_TOOL_SPLIT_PANE); + FXUtils.addClassTo(splitPanel, CssClasses.FILE_EDITOR_TOOL_SPLIT_PANE); } @Override - @FXThread + @FxThread protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { super.createToolComponents(container, root); - fragmentPreview = new FragmentShaderCodePreviewComponent(EDITOR.getAssetManager(), EDITOR.getRenderManager()); + final AssetManager assetManager = EditorUtil.getAssetManager(); + final RenderManager renderManager = EditorUtil.getRenderManager(); + + fragmentPreview = new FragmentShaderCodePreviewComponent(assetManager, renderManager); fragmentPreview.prefHeightProperty().bind(root.heightProperty()); - vertexPreview = new VertexShaderCodePreviewComponent(EDITOR.getAssetManager(), EDITOR.getRenderManager()); + vertexPreview = new VertexShaderCodePreviewComponent(assetManager, renderManager); vertexPreview.prefHeightProperty().bind(root.heightProperty()); - matDefPreview = new MaterialDefCodePreviewComponent(EDITOR.getAssetManager(), EDITOR.getRenderManager()); + matDefPreview = new MaterialDefCodePreviewComponent(assetManager, renderManager); matDefPreview.prefHeightProperty().bind(root.heightProperty()); container.addComponent(vertexPreview, PluginMessages.SNS_EDITOR_TOOL_VERTEX); @@ -359,7 +363,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container * * @return the fragment preview component. */ - @FXThread + @FxThread private @NotNull ShaderCodePreviewComponent getFragmentPreview() { return notNull(fragmentPreview); } @@ -369,7 +373,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container * * @return the vertex preview component. */ - @FXThread + @FxThread private @NotNull ShaderCodePreviewComponent getVertexPreview() { return notNull(vertexPreview); } @@ -379,13 +383,13 @@ protected void createToolComponents(@NotNull final EditorToolComponent container * * @return the material definition preview component. */ - @FXThread + @FxThread private @NotNull MaterialDefCodePreviewComponent getMatDefPreview() { return notNull(matDefPreview); } @Override - @FXThread + @FxThread protected void createActions(@NotNull final HBox container) { super.createActions(container); @@ -401,12 +405,12 @@ protected void createActions(@NotNull final HBox container) { FXUtils.addToPane(exportAction, importAction, container); - FXUtils.addClassesTo(exportAction, importAction, CSSClasses.FLAT_BUTTON, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON); + FXUtils.addClassesTo(exportAction, importAction, CssClasses.FLAT_BUTTON, CssClasses.FILE_EDITOR_TOOLBAR_BUTTON); DynamicIconSupport.addSupport(exportAction, importAction); } @Override - @FXThread + @FxThread protected void createToolbar(@NotNull final HBox container) { super.createToolbar(container); @@ -433,15 +437,15 @@ protected void createToolbar(@NotNull final HBox container) { FXUtils.addToPane(lightModeLabel, lightModeComboBox, container); FXUtils.addToPane(techniqueLabel, techniqueComboBox, addTechnique, container); - FXUtils.addClassTo(techniqueLabel, lightModeLabel, CSSClasses.FILE_EDITOR_TOOLBAR_LABEL); - FXUtils.addClassTo(techniqueComboBox, lightModeComboBox, CSSClasses.FILE_EDITOR_TOOLBAR_FIELD); - FXUtils.addClassesTo(addTechnique, CSSClasses.FLAT_BUTTON, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON); + FXUtils.addClassTo(techniqueLabel, lightModeLabel, CssClasses.FILE_EDITOR_TOOLBAR_LABEL); + FXUtils.addClassTo(techniqueComboBox, lightModeComboBox, CssClasses.FILE_EDITOR_TOOLBAR_FIELD); + FXUtils.addClassesTo(addTechnique, CssClasses.FLAT_BUTTON, CssClasses.FILE_EDITOR_TOOLBAR_BUTTON); } /** * Add new technique. */ - @FXThread + @FxThread private void addTechnique() { final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); @@ -452,7 +456,7 @@ private void addTechnique() { dialog.show(); } - @FXThread + @FxThread private boolean validateTechnique(@NotNull final VarTable vars) { final String name = vars.getString(PROP_TECHNIQUE_NAME); final MaterialDef materialDef = getMaterialDef(); @@ -460,7 +464,7 @@ private boolean validateTechnique(@NotNull final VarTable vars) { return techniqueDefs == null && !name.isEmpty(); } - @FXThread + @FxThread private void addTechnique(@NotNull final VarTable vars) { final ShaderNodeVariable vertexGlobal = new ShaderNodeVariable("vec4", "Global", "position", null, ""); @@ -514,19 +518,19 @@ private void addTechnique(@NotNull final VarTable vars) { /** * Export the result material definition as a file. */ - @FXThread + @FxThread private void export() { - UIUtils.openSaveAsDialog(this::export, FileExtensions.JME_MATERIAL_DEFINITION, ACTION_TESTER); + UiUtils.openSaveAsDialog(this::export, FileExtensions.JME_MATERIAL_DEFINITION, ACTION_TESTER); } /** * Import other material definition file to this project. */ - @FXThread + @FxThread private void importMatDef() { final ResourceManager resourceManager = ResourceManager.getInstance(); final Array resources = resourceManager.getAvailableResources(FileExtensions.JME_MATERIAL_DEFINITION); - UIUtils.openResourceAssetDialog(this::importMatDef, this::validateMatDef, resources); + UiUtils.openResourceAssetDialog(this::importMatDef, this::validateMatDef, resources); } /** @@ -535,7 +539,7 @@ private void importMatDef() { * @param assetPath the asset path. * @return the message or null if it's ok. */ - @FXThread + @FxThread private String validateMatDef(@NotNull final String assetPath) { final String message = StringVirtualAssetEditorDialog.DEFAULT_VALIDATOR.apply(assetPath); @@ -543,7 +547,7 @@ private String validateMatDef(@NotNull final String assetPath) { return message; } - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final MaterialDef materialDef = (MaterialDef) assetManager.loadAsset(assetPath); final Collection techniqueDefsNames = materialDef.getTechniqueDefsNames(); @@ -564,7 +568,7 @@ private String validateMatDef(@NotNull final String assetPath) { * * @param path the file. */ - @FXThread + @FxThread private void export(@NotNull final Path path) { final J3mdExporter exporter = new J3mdExporter(); @@ -584,10 +588,10 @@ private void export(@NotNull final Path path) { * * @param resource the resource. */ - @FXThread + @FxThread private void importMatDef(@NotNull final String resource) { - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final MaterialDef matDef = (MaterialDef) assetManager.loadAsset(resource); setMaterialDef(matDef); @@ -599,7 +603,7 @@ private void importMatDef(@NotNull final String resource) { * * @return the light modes combo box. */ - @FXThread + @FxThread private @NotNull ComboBox getLightModeComboBox() { return notNull(lightModeComboBox); } @@ -607,7 +611,7 @@ private void importMatDef(@NotNull final String resource) { /** * @return true if need to skip changes of light modes. */ - @FXThread + @FxThread private boolean isIgnoreLightModeChanges() { return ignoreLightModeChanges; } @@ -615,7 +619,7 @@ private boolean isIgnoreLightModeChanges() { /** * @param ignoreLightModeChanges true if need to skip changes of light modes. */ - @FXThread + @FxThread private void setIgnoreLightModeChanges(final boolean ignoreLightModeChanges) { this.ignoreLightModeChanges = ignoreLightModeChanges; } @@ -623,7 +627,7 @@ private void setIgnoreLightModeChanges(final boolean ignoreLightModeChanges) { /** * Handle changing the technique. */ - @FXThread + @FxThread private void changeTechnique(@Nullable final String newValue) { final Material currentMaterial = getCurrentMaterial(); @@ -657,7 +661,7 @@ private void changeTechnique(@Nullable final String newValue) { getFragmentPreview().load(techniqueDef); getVertexPreview().load(techniqueDef); - getEditor3DState().selectTechnique(currentMaterial, newValue); + getEditor3DPart().selectTechnique(currentMaterial, newValue); setIgnoreLightModeChanges(true); try { @@ -670,7 +674,7 @@ private void changeTechnique(@Nullable final String newValue) { /** * Handle changing the light mode of this current technique. */ - @FXThread + @FxThread private void changeLightMode(@Nullable final LightMode prevLightMode, @Nullable final LightMode newLightMode) { if (isIgnoreLightModeChanges() || prevLightMode == null || newLightMode == null) return; @@ -683,7 +687,7 @@ private void changeLightMode(@Nullable final LightMode prevLightMode, @Nullable /** * @return the project file. */ - @FXThread + @FxThread private @NotNull ShaderNodesProject getProject() { return notNull(project); } @@ -691,7 +695,7 @@ private void changeLightMode(@Nullable final LightMode prevLightMode, @Nullable /** * @param project the project file. */ - @FXThread + @FxThread private void setProject(@NotNull final ShaderNodesProject project) { this.project = project; } @@ -699,7 +703,7 @@ private void setProject(@NotNull final ShaderNodesProject project) { /** * @return the current built material. */ - @FXThread + @FxThread private @Nullable Material getCurrentMaterial() { return currentMaterial; } @@ -707,7 +711,7 @@ private void setProject(@NotNull final ShaderNodesProject project) { /** * @param currentMaterial the current built material. */ - @FXThread + @FxThread private void setCurrentMaterial(@Nullable final Material currentMaterial) { this.currentMaterial = currentMaterial; } @@ -717,7 +721,7 @@ private void setCurrentMaterial(@Nullable final Material currentMaterial) { * * @param materialDef the current edited material definition. */ - @FXThread + @FxThread private void setMaterialDef(@NotNull final MaterialDef materialDef) { this.materialDef = materialDef; } @@ -737,7 +741,7 @@ private void setMaterialDef(@NotNull final MaterialDef materialDef) { /** * Build material for shader nodes. */ - @FXThread + @FxThread private void buildMaterial() { final Material currentMaterial = getCurrentMaterial(); @@ -773,7 +777,7 @@ private void buildMaterial() { setCurrentMaterial(newMaterial); getShaderNodesContainer().notifyChangedMaterial(); - getEditor3DState().updateMaterial(newMaterial); + getEditor3DPart().updateMaterial(newMaterial); getMatDefPreview().load(newMaterial.getMaterialDef()); if (items.contains(currentTechnique)) { @@ -797,7 +801,7 @@ private void buildMaterial() { final Collection materialParams = materialDef.getMaterialParams(); final Collection techniqueDefsNames = materialDef.getTechniqueDefsNames(); - final MaterialDef newMaterialDef = new MaterialDef(EDITOR.getAssetManager(), materialDef.getAssetName()); + final MaterialDef newMaterialDef = new MaterialDef(EditorUtil.getAssetManager(), materialDef.getAssetName()); materialParams.stream() .filter(MatParamTexture.class::isInstance) @@ -827,7 +831,7 @@ private void buildMaterial() { } @Override - @FXThread + @FxThread public void notifyAddedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -835,7 +839,7 @@ public void notifyAddedMapping(@NotNull final ShaderNode shaderNode, @NotNull fi } @Override - @FXThread + @FxThread public void notifyRemovedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -843,7 +847,7 @@ public void notifyRemovedMapping(@NotNull final ShaderNode shaderNode, @NotNull } @Override - @FXThread + @FxThread public void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping oldMapping, @NotNull final VariableMapping newMapping) { buildMaterial(); @@ -851,7 +855,7 @@ public void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull container.refreshLines(); } - @FXThread + @FxThread @Override public void notifyAddedMatParameter(@NotNull final MatParam matParam, @NotNull final Vector2f location) { buildMaterial(); @@ -859,7 +863,7 @@ public void notifyAddedMatParameter(@NotNull final MatParam matParam, @NotNull f container.addMatParam(matParam, location); } - @FXThread + @FxThread @Override public void notifyRemovedMatParameter(@NotNull final MatParam matParam) { buildMaterial(); @@ -867,7 +871,7 @@ public void notifyRemovedMatParameter(@NotNull final MatParam matParam) { container.removeMatParam(matParam); } - @FXThread + @FxThread @Override public void notifyAddedAttribute(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location) { buildMaterial(); @@ -875,7 +879,7 @@ public void notifyAddedAttribute(@NotNull final ShaderNodeVariable variable, @No container.addNodeElement(variable, location); } - @FXThread + @FxThread @Override public void notifyRemovedAttribute(@NotNull final ShaderNodeVariable variable) { buildMaterial(); @@ -884,7 +888,7 @@ public void notifyRemovedAttribute(@NotNull final ShaderNodeVariable variable) { } @Override - @FXThread + @FxThread public void notifyAddedWorldParameter(@NotNull final UniformBinding binding, @NotNull final Vector2f location) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -892,7 +896,7 @@ public void notifyAddedWorldParameter(@NotNull final UniformBinding binding, @No } @Override - @FXThread + @FxThread public void notifyRemovedWorldParameter(@NotNull final UniformBinding binding) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -900,7 +904,7 @@ public void notifyRemovedWorldParameter(@NotNull final UniformBinding binding) { } @Override - @FXThread + @FxThread public void notifyAddedShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -908,7 +912,7 @@ public void notifyAddedShaderNode(@NotNull final ShaderNode shaderNode, @NotNull } @Override - @FXThread + @FxThread public void notifyRemovedRemovedShaderNode(@NotNull final ShaderNode shaderNode) { buildMaterial(); final ShaderNodesContainer container = getShaderNodesContainer(); @@ -916,7 +920,7 @@ public void notifyRemovedRemovedShaderNode(@NotNull final ShaderNode shaderNode) } @Override - @FXThread + @FxThread public void notifyChangeState(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location, final double width) { @@ -926,7 +930,7 @@ public void notifyChangeState(@NotNull final ShaderNode shaderNode, @NotNull fin } @Override - @FXThread + @FxThread public void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location, final double width) { @@ -936,7 +940,7 @@ public void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNu } @Override - @FXThread + @FxThread public @Nullable Vector2f getLocation(@NotNull final ShaderNode shaderNode) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return null; @@ -945,7 +949,7 @@ public void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNu } @Override - @FXThread + @FxThread public @Nullable Vector2f getLocation(@NotNull final ShaderNodeVariable variable) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return null; @@ -954,7 +958,7 @@ public void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNu } @Override - @FXThread + @FxThread public double getWidth(@NotNull final ShaderNode shaderNode) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return 0D; @@ -963,7 +967,7 @@ public double getWidth(@NotNull final ShaderNode shaderNode) { } @Override - @FXThread + @FxThread public double getWidth(@NotNull final ShaderNodeVariable variable) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return 0D; @@ -972,7 +976,7 @@ public double getWidth(@NotNull final ShaderNodeVariable variable) { } @Override - @FXThread + @FxThread public @Nullable Vector2f getGlobalNodeLocation(final boolean input) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return null; @@ -980,7 +984,7 @@ public double getWidth(@NotNull final ShaderNodeVariable variable) { } @Override - @FXThread + @FxThread public double getGlobalNodeWidth(final boolean input) { final TechniqueDefState state = getTechniqueDefState(); if (state == null) return 0D; @@ -988,19 +992,19 @@ public double getGlobalNodeWidth(final boolean input) { } @Override - @FXThread + @FxThread public void notifyAddedTechnique(@NotNull final TechniqueDef techniqueDef) { buildMaterial(); } @Override - @FXThread + @FxThread public void notifyRemovedTechnique(@NotNull final TechniqueDef techniqueDef) { buildMaterial(); } @Override - @FXThread + @FxThread public void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vector2f location, final double width) { final TechniqueDefState state = getTechniqueDefState(); @@ -1020,7 +1024,7 @@ public void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vect * * @return the current technique definition state. */ - @FXThread + @FxThread private @Nullable TechniqueDefState getTechniqueDefState() { final ShaderNodesEditorState editorState = getEditorState(); @@ -1035,9 +1039,9 @@ public void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vect } @Override - @FXThread - public void notifyFXChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { - super.notifyFXChangeProperty(object, propertyName); + @FxThread + public void notifyFxChangeProperty(@NotNull final Object object, @NotNull final String propertyName) { + super.notifyFxChangeProperty(object, propertyName); if (object instanceof MatParam) { final PropertyEditor propertyEditor = getPropertyEditor(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java index e6118b4..e965f13 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.editor.state; import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.editor.state.impl.AbstractEditorState; import org.jetbrains.annotations.NotNull; @@ -50,7 +50,7 @@ public ShaderNodeState(@NotNull final String name, @NotNull final Vector2f locat * * @return the name of a shader nodes. */ - @FXThread + @FxThread public @NotNull String getName() { return name; } @@ -60,7 +60,7 @@ public ShaderNodeState(@NotNull final String name, @NotNull final Vector2f locat * * @param name the name of a shader nodes. */ - @FXThread + @FxThread public void setName(@NotNull final String name) { this.name = name; } @@ -70,7 +70,7 @@ public void setName(@NotNull final String name) { * * @return the location of a shader nodes. */ - @FXThread + @FxThread public @NotNull Vector2f getLocation() { return location; } @@ -80,7 +80,7 @@ public void setName(@NotNull final String name) { * * @param location the location of a shader nodes. */ - @FXThread + @FxThread public void setLocation(@NotNull final Vector2f location) { this.location = location; } @@ -90,7 +90,7 @@ public void setLocation(@NotNull final Vector2f location) { * * @return the width of a shader nodes. */ - @FXThread + @FxThread public int getWidth() { return width; } @@ -100,7 +100,7 @@ public int getWidth() { * * @param width the width of a shader nodes. */ - @FXThread + @FxThread public void setWidth(final int width) { this.width = width; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java index 2619bec..06d1894 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.editor.state; import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.component.editor.state.impl.AbstractEditorState; import org.jetbrains.annotations.NotNull; @@ -60,7 +60,7 @@ public ShaderNodeVariableState(@NotNull final String name, @NotNull final String * * @return the name of a variable. */ - @FXThread + @FxThread public @NotNull String getName() { return name; } @@ -70,7 +70,7 @@ public ShaderNodeVariableState(@NotNull final String name, @NotNull final String * * @param name the name of a variable. */ - @FXThread + @FxThread public void setName(@NotNull final String name) { this.name = name; } @@ -80,7 +80,7 @@ public void setName(@NotNull final String name) { * * @return the namespace of a variable. */ - @FXThread + @FxThread public @NotNull String getNameSpace() { return nameSpace; } @@ -90,7 +90,7 @@ public void setName(@NotNull final String name) { * * @param nameSpace the namespace of a variable. */ - @FXThread + @FxThread public void setNameSpace(@NotNull final String nameSpace) { this.nameSpace = nameSpace; } @@ -100,7 +100,7 @@ public void setNameSpace(@NotNull final String nameSpace) { * * @return the location of a variable. */ - @FXThread + @FxThread public @NotNull Vector2f getLocation() { return location; } @@ -110,7 +110,7 @@ public void setNameSpace(@NotNull final String nameSpace) { * * @param location the location of a variable. */ - @FXThread + @FxThread public void setLocation(@NotNull final Vector2f location) { this.location = location; } @@ -120,7 +120,7 @@ public void setLocation(@NotNull final Vector2f location) { * * @return the width of a variable. */ - @FXThread + @FxThread public int getWidth() { return width; } @@ -130,7 +130,7 @@ public int getWidth() { * * @param width the width of a variable. */ - @FXThread + @FxThread public void setWidth(final int width) { this.width = width; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java index bdd69a1..8be4555 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.material.MaterialDef; import com.jme3.material.TechniqueDef; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesFileEditor; import com.ss.editor.ui.component.editor.state.impl.EditorMaterialEditorState; import com.ss.rlib.logging.Logger; @@ -42,13 +42,13 @@ public ShaderNodesEditorState() { * * @return the states of technique definitions. */ - @FXThread + @FxThread public @NotNull List getTechniqueDefStates() { return techniqueDefStates; } @Override - @FXThread + @FxThread public void setChangeHandler(@NotNull final Runnable changeHandler) { super.setChangeHandler(changeHandler); techniqueDefStates.forEach(state -> state.setChangeHandler(changeHandler)); @@ -60,7 +60,7 @@ public void setChangeHandler(@NotNull final Runnable changeHandler) { * @param techniqueDefName the name of a technique definition. * @return the state. */ - @FXThread + @FxThread public @NotNull TechniqueDefState getState(@NotNull final String techniqueDefName) { final Optional result = techniqueDefStates.stream() @@ -85,7 +85,7 @@ public void setChangeHandler(@NotNull final Runnable changeHandler) { * * @param materialDef the material definition. */ - @FXThread + @FxThread public void cleanUp(@NotNull final MaterialDef materialDef) { LOGGER.debug(this, editorState -> "The state before cleanup: " + editorState); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java index 23e881e..6982a7c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java @@ -8,7 +8,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.AttributeShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MaterialShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.WorldShaderNodeElement; @@ -92,7 +92,7 @@ public TechniqueDefState(@NotNull final String name) { * @param materialDef the material definition. * @param techniqueDef the technique definition. */ - @FXThread + @FxThread public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final TechniqueDef techniqueDef) { for (final Iterator iterator = shaderVariableStates.iterator(); iterator.hasNext(); ) { @@ -147,7 +147,7 @@ public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final Techn * @param location the location. * @param width the width. */ - @FXThread + @FxThread public void notifyChange(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location, final double width) { @@ -179,7 +179,7 @@ public void notifyChange(@NotNull final ShaderNodeVariable variable, @NotNull fi * @param location the location. * @param width the width. */ - @FXThread + @FxThread public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location, final double width) { @@ -208,7 +208,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * @param shaderNode the shader nodes. * @return the state or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeState getState(@NotNull final ShaderNode shaderNode) { return shaderNodeStates.stream().filter(variableState -> variableState.getName().equals(shaderNode.getName())) .findAny().orElse(null); @@ -220,7 +220,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * @param variable the shader nodes variable. * @return the state or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeVariableState getState(@Nullable final ShaderNodeVariable variable) { if (variable == null) return null; return shaderVariableStates.stream() @@ -234,7 +234,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * * @return the name of technique definition. */ - @FXThread + @FxThread public @NotNull String getName() { return name; } @@ -244,7 +244,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * * @return the location of input nodes. */ - @FXThread + @FxThread public @NotNull Vector2f getInputNodeLocation() { return inputNodeLocation; } @@ -254,7 +254,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * * @return the location of output nodes. */ - @FXThread + @FxThread public @NotNull Vector2f getOutputNodeLocation() { return outputNodeLocation; } @@ -264,7 +264,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * * @param inputNodeLocation the location of input nodes. */ - @FXThread + @FxThread public void setInputNodeLocation(@NotNull final Vector2f inputNodeLocation) { final Vector2f prev = getInputNodeLocation(); this.inputNodeLocation = inputNodeLocation; @@ -276,7 +276,7 @@ public void setInputNodeLocation(@NotNull final Vector2f inputNodeLocation) { * * @param outputNodeLocation the location of output nodes. */ - @FXThread + @FxThread public void setOutputNodeLocation(@NotNull final Vector2f outputNodeLocation) { final Vector2f prev = getOutputNodeLocation(); this.outputNodeLocation = outputNodeLocation; @@ -288,7 +288,7 @@ public void setOutputNodeLocation(@NotNull final Vector2f outputNodeLocation) { * * @return the width of output nodes. */ - @FXThread + @FxThread public int getOutputNodeWidth() { return outputNodeWidth; } @@ -298,7 +298,7 @@ public int getOutputNodeWidth() { * * @return the width of input nodes. */ - @FXThread + @FxThread public int getInputNodeWidth() { return inputNodeWidth; } @@ -308,7 +308,7 @@ public int getInputNodeWidth() { * * @param outputNodeWidth the width of output nodes. */ - @FXThread + @FxThread public void setOutputNodeWidth(final int outputNodeWidth) { final int prev = getOutputNodeWidth(); this.outputNodeWidth = outputNodeWidth; @@ -320,7 +320,7 @@ public void setOutputNodeWidth(final int outputNodeWidth) { * * @param inputNodeWidth the width of input nodes. */ - @FXThread + @FxThread public void setInputNodeWidth(final int inputNodeWidth) { final int prev = getInputNodeWidth(); this.inputNodeWidth = inputNodeWidth; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/CodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/CodePreviewComponent.java index 77c7938..8b9063c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/CodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/CodePreviewComponent.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.renderer.RenderManager; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.code.BaseCodeArea; import javafx.scene.layout.VBox; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public CodePreviewComponent(@NotNull final AssetManager assetManager, @NotNull f createComponents(); } - @FXThread + @FxThread protected abstract void createComponents(); /** @@ -48,7 +48,7 @@ public CodePreviewComponent(@NotNull final AssetManager assetManager, @NotNull f * * @return the render manager. */ - @FXThread + @FxThread protected @NotNull RenderManager getRenderManager() { return renderManager; } @@ -58,7 +58,7 @@ public CodePreviewComponent(@NotNull final AssetManager assetManager, @NotNull f * * @return the asset manager. */ - @FXThread + @FxThread protected @NotNull AssetManager getAssetManager() { return assetManager; } @@ -68,7 +68,7 @@ public CodePreviewComponent(@NotNull final AssetManager assetManager, @NotNull f * * @return the code area. */ - @FXThread + @FxThread protected @NotNull BaseCodeArea getCodeArea() { return notNull(codeArea); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/material/definition/MaterialDefCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/material/definition/MaterialDefCodePreviewComponent.java index 4fe63f0..a4800c5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/material/definition/MaterialDefCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/material/definition/MaterialDefCodePreviewComponent.java @@ -6,7 +6,7 @@ import com.jme3.material.MaterialDef; import com.jme3.material.plugin.export.materialdef.J3mdExporter; import com.jme3.renderer.RenderManager; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.preview.CodePreviewComponent; import com.ss.editor.ui.control.code.BaseCodeArea; import com.ss.editor.ui.control.code.MaterialDefinitionCodeArea; @@ -29,7 +29,7 @@ public MaterialDefCodePreviewComponent(@NotNull final AssetManager assetManager, } @Override - @FXThread + @FxThread protected void createComponents() { codeArea = new MaterialDefinitionCodeArea(); @@ -45,7 +45,7 @@ protected void createComponents() { * * @param materialDef the material definition. */ - @FXThread + @FxThread public void load(@NotNull final MaterialDef materialDef) { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/FragmentShaderCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/FragmentShaderCodePreviewComponent.java index 8ac28a6..8b3b0f5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/FragmentShaderCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/FragmentShaderCodePreviewComponent.java @@ -3,7 +3,7 @@ import com.jme3.asset.AssetManager; import com.jme3.renderer.RenderManager; import com.jme3.shader.Shader; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import org.jetbrains.annotations.NotNull; /** @@ -19,7 +19,7 @@ public FragmentShaderCodePreviewComponent(@NotNull final AssetManager assetManag } @Override - @FXThread + @FxThread protected @NotNull Shader.ShaderType getShaderType() { return Shader.ShaderType.Fragment; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java index 212e86f..83d6ed6 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/ShaderCodePreviewComponent.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.component.preview.shader; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_CODE_PREVIEW_CONTAINER; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_CODE_PREVIEW_CONTAINER; import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.asset.AssetManager; import com.jme3.material.TechniqueDef; @@ -10,14 +10,14 @@ import com.jme3.shader.Shader; import com.jme3.shader.ShaderGenerator; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.shader.nodes.ui.component.preview.CodePreviewComponent; import com.ss.editor.ui.control.code.BaseCodeArea; import com.ss.editor.ui.control.code.GLSLCodeArea; -import com.ss.editor.ui.css.CSSClasses; +import com.ss.editor.ui.css.CssClasses; import com.ss.rlib.ui.util.FXUtils; import javafx.collections.ObservableList; import javafx.scene.control.ComboBox; @@ -55,7 +55,7 @@ public ShaderCodePreviewComponent(@NotNull final AssetManager assetManager, } @Override - @FXThread + @FxThread protected void createComponents() { final Label languageLabel = new Label(Messages.MODEL_PROPERTY_LANGUAGE + ":"); @@ -77,7 +77,7 @@ protected void createComponents() { FXUtils.addToPane(languageContainer, this); FXUtils.addToPane(codeArea, this); - FXUtils.addClassTo(languageContainer, CSSClasses.DEF_HBOX); + FXUtils.addClassTo(languageContainer, CssClasses.DEF_HBOX); } /** @@ -85,7 +85,7 @@ protected void createComponents() { * * @return the shader type. */ - @FXThread + @FxThread protected abstract @NotNull Shader.ShaderType getShaderType(); /** @@ -93,7 +93,7 @@ protected void createComponents() { * * @param newValue the new shader language or null. */ - @FXThread + @FxThread private void changeLanguage(@Nullable final String newValue) { final BaseCodeArea codeArea = getCodeArea(); @@ -126,7 +126,7 @@ private void changeLanguage(@Nullable final String newValue) { @FromAnyThread public void load(@NotNull final TechniqueDef techniqueDef) { final ExecutorManager executorManager = ExecutorManager.getInstance(); - executorManager.addJMETask(() -> generateShader(techniqueDef)); + executorManager.addJmeTask(() -> generateShader(techniqueDef)); } /** @@ -134,7 +134,7 @@ public void load(@NotNull final TechniqueDef techniqueDef) { * * @param techniqueDef the technique definition. */ - @JMEThread + @JmeThread private void generateShader(@NotNull final TechniqueDef techniqueDef) { final Renderer renderer = getRenderManager().getRenderer(); @@ -145,13 +145,13 @@ private void generateShader(@NotNull final TechniqueDef techniqueDef) { this.shader = abstractShaderGenerator.generateShader(""); final ExecutorManager executorManager = ExecutorManager.getInstance(); - executorManager.addFXTask(this::loadShader); + executorManager.addFxTask(this::loadShader); } /** * Load languages from the generated shader. */ - @FXThread + @FxThread private void loadShader() { final ComboBox languageBox = getLanguageBox(); @@ -173,7 +173,7 @@ private void loadShader() { * * @return the box with language options. */ - @FXThread + @FxThread private @NotNull ComboBox getLanguageBox() { return notNull(languageBox); } @@ -183,7 +183,7 @@ private void loadShader() { * * @return the current shader. */ - @FXThread + @FxThread protected @NotNull Shader getShader() { return notNull(shader); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/VertexShaderCodePreviewComponent.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/VertexShaderCodePreviewComponent.java index f62ebd1..291a9f3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/VertexShaderCodePreviewComponent.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/preview/shader/VertexShaderCodePreviewComponent.java @@ -3,7 +3,7 @@ import com.jme3.asset.AssetManager; import com.jme3.renderer.RenderManager; import com.jme3.shader.Shader; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import org.jetbrains.annotations.NotNull; /** @@ -19,7 +19,7 @@ public VertexShaderCodePreviewComponent(@NotNull final AssetManager assetManager } @Override - @FXThread + @FxThread protected @NotNull Shader.ShaderType getShaderType() { return Shader.ShaderType.Vertex; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java index 4549657..f9f6fe4 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java @@ -1,11 +1,11 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_HEADER; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_HEADER; import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.*; import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.remove.RemoveRelationShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.line.VariableLine; @@ -127,7 +127,7 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull * * @return the container of nodes parameters. */ - @FXThread + @FxThread protected @NotNull VBox getParametersContainer() { return parametersContainer; } @@ -137,7 +137,7 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull * * @return the tooltip. */ - @FXThread + @FxThread protected @NotNull Optional createTooltip() { return Optional.empty(); } @@ -147,7 +147,7 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull * * @param event the context menu requested event. */ - @FXThread + @FxThread private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { final ShaderNodesContainer container = getContainer(); container.handleContextMenuEvent(event); @@ -161,7 +161,7 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { * @param outputParameter the output parameter. * @return true of we can attach. */ - @FXThread + @FxThread public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { @@ -185,7 +185,7 @@ public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, * @param inputParameter the input parameter. * @param outputParameter the output parameter. */ - @FXThread + @FxThread public void attach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { } @@ -193,7 +193,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, /** * @return the container of this nodes. */ - @FXThread + @FxThread public @NotNull ShaderNodesContainer getContainer() { return container; } @@ -201,7 +201,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, /** * @return the shader object. */ - @FXThread + @FxThread public @NotNull T getObject() { return object; } @@ -214,7 +214,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, * @param input true if the variable is input variable. * @return the parameter or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { return parametersContainer.getChildren().stream() @@ -230,7 +230,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, * * @return the title text of this nodes. */ - @FXThread + @FxThread protected @NotNull String getTitleText() { return "Title"; } @@ -238,7 +238,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, /** * Create UI content of this nodes. */ - @FXThread + @FxThread protected void createContent() { final StackPane header = new StackPane(); @@ -256,7 +256,7 @@ protected void createContent() { /** * Reset layout of this nodes. */ - @FXThread + @FxThread public void resetLayout() { final double layoutX = getLayoutX(); final double layoutY = getLayoutY(); @@ -271,7 +271,7 @@ public void resetLayout() { * * @param container the parameters container. */ - @FXThread + @FxThread protected void fillParameters(@NotNull final VBox container) { } @@ -280,7 +280,7 @@ protected void fillParameters(@NotNull final VBox container) { * * @param event the mouse event. */ - @FXThread + @FxThread private void handleMouseDragged(@NotNull final MouseEvent event) { if (event.getTarget() instanceof SocketElement) { @@ -320,7 +320,7 @@ private void handleMouseDragged(@NotNull final MouseEvent event) { * * @param event the mouse released event. */ - @FXThread + @FxThread private void handleMouseReleased(@NotNull final MouseEvent event) { if (isResizing()) { setResizing(false); @@ -338,7 +338,7 @@ private void handleMouseReleased(@NotNull final MouseEvent event) { * * @param event the mouse moved event. */ - @FXThread + @FxThread private void handleMouseMoved(@NotNull final MouseEvent event) { if (event.getTarget() instanceof SocketElement) { @@ -358,7 +358,7 @@ private void handleMouseMoved(@NotNull final MouseEvent event) { * * @param selected true if this nodes is selected. */ - @FXThread + @FxThread public void setSelected(final boolean selected) { this.selected.setValue(selected); } @@ -368,7 +368,7 @@ public void setSelected(final boolean selected) { * * @param event the mouse pressed event. */ - @FXThread + @FxThread private void handleMousePressed(@NotNull final MouseEvent event) { if (event.getTarget() instanceof SocketElement) { @@ -402,7 +402,7 @@ private void handleMousePressed(@NotNull final MouseEvent event) { * @param event the mouse event. * @return true if we can start to resize. */ - @FXThread + @FxThread protected boolean isInResizableZone(@NotNull final MouseEvent event) { return event.getX() > (getWidth() - RESIZE_MARGIN); } @@ -410,7 +410,7 @@ protected boolean isInResizableZone(@NotNull final MouseEvent event) { /** * @return true if this nodes is dragging now. */ - @FXThread + @FxThread protected boolean isDragging() { return dragging; } @@ -418,7 +418,7 @@ protected boolean isDragging() { /** * @param dragging true if this nodes is dragging now. */ - @FXThread + @FxThread protected void setDragging(final boolean dragging) { this.dragging = dragging; } @@ -426,7 +426,7 @@ protected void setDragging(final boolean dragging) { /** * @return true if this nodes is resizing now. */ - @FXThread + @FxThread protected boolean isResizing() { return resizing; } @@ -434,7 +434,7 @@ protected boolean isResizing() { /** * @param resizing true if this nodes is resizing now. */ - @FXThread + @FxThread protected void setResizing(final boolean resizing) { this.resizing = resizing; } @@ -444,7 +444,7 @@ protected void setResizing(final boolean resizing) { * * @return the action or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return null; } @@ -455,7 +455,7 @@ protected void setResizing(final boolean resizing) { * @param line the line. * @return the action or null. */ - @FXThread + @FxThread public @Nullable ShaderNodeAction getDetachAction(@NotNull final VariableLine line) { return new RemoveRelationShaderNodeAction(getContainer(), line, Vector2f.ZERO); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java index 1e7191e..58d2ed3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODES_ROOT; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODES_ROOT; import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.hasInMappingByRightVar; import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.hasOutMappingByLeftVar; import static com.ss.rlib.util.ObjectUtils.notNull; @@ -11,7 +11,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.*; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -148,7 +148,7 @@ public ShaderNodesContainer(@NotNull final ShaderNodesChangeConsumer changeConsu /** * Notify about changed preview material. */ - @FXThread + @FxThread public void notifyChangedMaterial() { getNodeElements().stream() .filter(MaterialShaderNodeElement.class::isInstance) @@ -161,7 +161,7 @@ public void notifyChangedMaterial() { * * @return all current nodes elements. */ - @FXThread + @FxThread private @NotNull Array> getNodeElements() { return nodeElements; } @@ -169,7 +169,7 @@ public void notifyChangedMaterial() { /** * @return the change consumer. */ - @FXThread + @FxThread public @NotNull ShaderNodesChangeConsumer getChangeConsumer() { return changeConsumer; } @@ -177,7 +177,7 @@ public void notifyChangedMaterial() { /** * Reset all layouts. */ - @FXThread + @FxThread private void invalidateSizes() { final ShaderNodesChangeConsumer consumer = getChangeConsumer(); @@ -209,13 +209,13 @@ private void invalidateSizes() { nodeElement.resize(width, nodeElement.getHeight()); } - EXECUTOR_MANAGER.addFXTask(this::invalidateLayout); + EXECUTOR_MANAGER.addFxTask(this::invalidateLayout); } /** * Update all layouts. */ - @FXThread + @FxThread private void invalidateLayout() { final ShaderNodesChangeConsumer consumer = getChangeConsumer(); @@ -260,7 +260,7 @@ private void invalidateLayout() { /** * Layout nodes. */ - @FXThread + @FxThread private void layoutNodes() { final Array> nodeElements = getNodeElements(); @@ -376,7 +376,7 @@ private void layoutNodes() { /** * Reset all layouts. */ - @FXThread + @FxThread private void resetLayout() { final Array> nodeElements = getNodeElements(); nodeElements.forEach(ShaderNodeElement::resetLayout); @@ -387,7 +387,7 @@ private void resetLayout() { * * @return the temp line to show a process of binding variables. */ - @FXThread + @FxThread private @Nullable TempLine getTempLine() { return tempLine; } @@ -397,7 +397,7 @@ private void resetLayout() { * * @param tempLine the temp line to show a process of binding variables. */ - @FXThread + @FxThread private void setTempLine(@Nullable final TempLine tempLine) { this.tempLine = tempLine; } @@ -407,7 +407,7 @@ private void setTempLine(@Nullable final TempLine tempLine) { * * @param sourceSocket the source socket. */ - @FXThread + @FxThread public void startAttaching(@NotNull final SocketElement sourceSocket) { TempLine tempLine = getTempLine(); @@ -428,7 +428,7 @@ public void startAttaching(@NotNull final SocketElement sourceSocket) { * * @param dragEvent the drag over event. */ - @FXThread + @FxThread private void handleDragOver(@NotNull final DragEvent dragEvent) { if (dragEvent.getGestureSource() instanceof SocketElement) { updateAttaching(dragEvent.getSceneX(), dragEvent.getSceneY()); @@ -441,7 +441,7 @@ private void handleDragOver(@NotNull final DragEvent dragEvent) { * * @param event the mouse event. */ - @FXThread + @FxThread private void handleMouseClicked(@NotNull final MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY && contextMenu.isShowing()) { contextMenu.hide(); @@ -453,7 +453,7 @@ private void handleMouseClicked(@NotNull final MouseEvent event) { * * @param event the context menu event. */ - @FXThread + @FxThread public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { final Object source = event.getSource(); @@ -509,7 +509,7 @@ public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { * @param sceneX the sceneX. * @param sceneY the sceneY. */ - @FXThread + @FxThread public void updateAttaching(final double sceneX, final double sceneY) { final TempLine tempLine = getTempLine(); @@ -522,7 +522,7 @@ public void updateAttaching(final double sceneX, final double sceneY) { /** * Handle finish the process of attaching. */ - @FXThread + @FxThread public void finishAttaching() { final TempLine tempLine = getTempLine(); @@ -537,7 +537,7 @@ public void finishAttaching() { * * @param requester the nodes to select. */ - @FXThread + @FxThread public void requestSelect(@NotNull final ShaderNodeElement requester) { final ObservableList children = root.getChildren(); @@ -554,7 +554,7 @@ public void requestSelect(@NotNull final ShaderNodeElement requester) { * * @return the root component to place all nodes. */ - @FXThread + @FxThread private @NotNull Pane getRoot() { return root; } @@ -564,7 +564,7 @@ public void requestSelect(@NotNull final ShaderNodeElement requester) { * * @param techniqueDef the technique. */ - @FXThread + @FxThread public void show(@NotNull final TechniqueDef techniqueDef) { if (techniqueDef.equals(this.techniqueDef)) return; @@ -619,7 +619,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { nodeElements.forEach(root.getChildren(), (nodeElement, nodes) -> nodes.add(nodeElement)); refreshLines(); - EXECUTOR_MANAGER.addFXTask(this::invalidateSizes); + EXECUTOR_MANAGER.addFxTask(this::invalidateSizes); } /** @@ -628,7 +628,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param leftVariable the left variable. * @return the list of nodes. */ - @FXThread + @FxThread public @NotNull List findWithLeftOutputVar(@NotNull final ShaderNodeVariable leftVariable) { return root.getChildren().stream() .filter(MainShaderNodeElement.class::isInstance) @@ -644,7 +644,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param name the name. * @return the found shader node or null. */ - @FXThread + @FxThread public @Nullable ShaderNode findShaderNodeByName(@NotNull final String name) { if (MaterialShaderNodeElement.NAMESPACE.equals(name) || GlobalShaderNodeElement.NAMESPACE.equals(name) || @@ -666,12 +666,12 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param shaderNode the shader node. * @return the list of used shader nodes. */ - @FXThread + @FxThread public @NotNull List findUsedFrom(@NotNull final ShaderNode shaderNode) { return findUsedFrom(new ArrayList<>(), shaderNode); } - @FXThread + @FxThread private @NotNull List findUsedFrom(@NotNull final List result, @NotNull final ShaderNode shaderNode) { @@ -698,7 +698,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param type the type. * @return the list of nodes. */ - @FXThread + @FxThread public @NotNull List findWithRightInputVar(@NotNull final ShaderNodeVariable rightVariable, @NotNull final Class type) { return root.getChildren().stream() @@ -715,7 +715,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param variable the variable. * @return the nodes element or null. */ - @FXThread + @FxThread private @Nullable ShaderNodeElement findNodeElementByVariable(@NotNull final ShaderNodeVariable variable) { return (ShaderNodeElement) root.getChildren().stream() .filter(ShaderNodeElement.class::isInstance) @@ -730,7 +730,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param object the object. * @return the nodes element or null. */ - @FXThread + @FxThread private @Nullable ShaderNodeElement findNodeElementByObject(@NotNull final Object object) { return (ShaderNodeElement) root.getChildren().stream() .filter(ShaderNodeElement.class::isInstance) @@ -747,7 +747,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param input true if the variable is input variable. * @return the parameter or null. */ - @FXThread + @FxThread private @Nullable ShaderNodeParameter findByVariable(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { return root.getChildren().stream() @@ -764,7 +764,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * @param matParam the new material parameter. * @param location the location. */ - @FXThread + @FxThread public void addMatParam(@NotNull final MatParam matParam, @NotNull final Vector2f location) { addNodeElement(MaterialShaderNodeElement.toVariable(matParam), location); } @@ -775,7 +775,7 @@ public void addMatParam(@NotNull final MatParam matParam, @NotNull final Vector2 * @param binding the binding. * @param location the location. */ - @FXThread + @FxThread public void addWorldParam(@NotNull final UniformBinding binding, @NotNull final Vector2f location) { addNodeElement(WorldShaderNodeElement.toVariable(binding), location); } @@ -786,7 +786,7 @@ public void addWorldParam(@NotNull final UniformBinding binding, @NotNull final * @param shaderNode the new shader nodes. * @param location the location. */ - @FXThread + @FxThread public void addShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location) { final ShaderNodeDefinition definition = shaderNode.getDefinition(); @@ -809,7 +809,7 @@ public void addShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final V * @param variable the new shader nodes variable. * @param location the location. */ - @FXThread + @FxThread public void addNodeElement(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location) { final ShaderNodeElement nodeElement = createNodeElement(variable); @@ -826,7 +826,7 @@ public void addNodeElement(@NotNull final ShaderNodeVariable variable, @NotNull * @param nodeElement the new nodes element. * @param location the location. */ - @FXThread + @FxThread private void addNodeElement(@NotNull final ShaderNodeElement nodeElement, @NotNull final Vector2f location) { final ObservableList children = root.getChildren(); @@ -838,7 +838,7 @@ private void addNodeElement(@NotNull final ShaderNodeElement nodeElement, @No refreshLines(); EXECUTOR_MANAGER.schedule(() -> { - EXECUTOR_MANAGER.addFXTask(() -> { + EXECUTOR_MANAGER.addFxTask(() -> { nodeElement.setLayoutX(location.getX()); nodeElement.setLayoutY(location.getY()); }); @@ -850,7 +850,7 @@ private void addNodeElement(@NotNull final ShaderNodeElement nodeElement, @No * * @param matParam the material parameter. */ - @FXThread + @FxThread public void removeMatParam(@NotNull final MatParam matParam) { removeNodeElement(MaterialShaderNodeElement.toVariable(matParam)); } @@ -860,7 +860,7 @@ public void removeMatParam(@NotNull final MatParam matParam) { * * @param binding the world parameter. */ - @FXThread + @FxThread public void removeWorldParam(@NotNull final UniformBinding binding) { removeNodeElement(WorldShaderNodeElement.toVariable(binding)); } @@ -870,7 +870,7 @@ public void removeWorldParam(@NotNull final UniformBinding binding) { * * @param shaderNode the shader nodes. */ - @FXThread + @FxThread public void removeShaderNode(@NotNull final ShaderNode shaderNode) { final ShaderNodeElement nodeElement = findNodeElementByObject(shaderNode); if (nodeElement == null) return; @@ -882,7 +882,7 @@ public void removeShaderNode(@NotNull final ShaderNode shaderNode) { * * @param variable the variable. */ - @FXThread + @FxThread public void removeNodeElement(@NotNull final ShaderNodeVariable variable) { final ShaderNodeElement nodeElement = findNodeElementByVariable(variable); @@ -898,7 +898,7 @@ public void removeNodeElement(@NotNull final ShaderNodeVariable variable) { * * @param nodeElement the nodes element. */ - @FXThread + @FxThread private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) { root.getChildren().remove(nodeElement); getNodeElements().slowRemove(nodeElement); @@ -911,7 +911,7 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) * @param variable the variable. * @return the nodes element. */ - @FXThread + @FxThread private @Nullable ShaderNodeElement createNodeElement(@NotNull ShaderNodeVariable variable) { ShaderNodeElement nodeElement = null; @@ -932,7 +932,7 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) * * @return the current technique definition. */ - @FXThread + @FxThread public @NotNull TechniqueDef getTechniqueDef() { return notNull(techniqueDef); } @@ -942,7 +942,7 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) * * @return the current material definition. */ - @FXThread + @FxThread public @NotNull MaterialDef getMaterialDef() { return getChangeConsumer().getMaterialDef(); } @@ -950,7 +950,7 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) /** * Refresh all lines. */ - @FXThread + @FxThread public void refreshLines() { final ObservableList children = root.getChildren(); @@ -985,7 +985,7 @@ public void refreshLines() { * @param mappings the mappings. * @param fromOutputMapping true if it's from output mapping. */ - @FXThread + @FxThread private void buildLines(@NotNull final ObservableList children, @NotNull final List mappings, final boolean fromOutputMapping) { @@ -1009,7 +1009,7 @@ private void buildLines(@NotNull final ObservableList children, @NotNull f /** * Update scale value. */ - @FXThread + @FxThread private void updateScale() { root.setScaleX(scaleValue); root.setScaleY(scaleValue); @@ -1020,7 +1020,7 @@ private void updateScale() { * * @param event the scroll event. */ - @FXThread + @FxThread private void handleScrollEvent(@NotNull final ScrollEvent event) { final double zoomFactor = event.getDeltaY() * ZOOM_INTENSITY; @@ -1058,7 +1058,7 @@ private void handleScrollEvent(@NotNull final ScrollEvent event) { * * @param nodeElement the nodes element. */ - @FXThread + @FxThread public void notifyMoved(@NotNull final ShaderNodeElement nodeElement) { notifyResized(nodeElement); } @@ -1068,7 +1068,7 @@ public void notifyMoved(@NotNull final ShaderNodeElement nodeElement) { * * @param nodeElement the nodes element. */ - @FXThread + @FxThread public void notifyResized(@NotNull final ShaderNodeElement nodeElement) { final Object object = nodeElement.getObject(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java index 8414da0..9c83383 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.action; import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import javafx.scene.control.MenuItem; import javafx.scene.image.Image; @@ -53,7 +53,7 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull /** * @return the location. */ - @FXThread + @FxThread public @NotNull Vector2f getLocation() { return location; } @@ -61,7 +61,7 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull /** * @return the shader nodes container. */ - @FXThread + @FxThread public @NotNull ShaderNodesContainer getContainer() { return container; } @@ -69,7 +69,7 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull /** * @return the additional object. */ - @FXThread + @FxThread public @NotNull T getObject() { return object; } @@ -79,13 +79,13 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull * * @return the name of this action. */ - @FXThread + @FxThread protected abstract @NotNull String getName(); /** * Execute this action. */ - @FXThread + @FxThread protected void process() { } @@ -94,7 +94,7 @@ protected void process() { * * @return he icon or null. */ - @FXThread + @FxThread protected @Nullable Image getIcon() { return null; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java index 5e54723..888a54c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java @@ -7,7 +7,7 @@ import com.jme3.math.Vector2f; import com.jme3.scene.VertexBuffer; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.add.AddAttributeOperation; @@ -52,19 +52,19 @@ public AddAttributeShaderNodeAction(@NotNull final ShaderNodesContainer containe } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.VERTEX_ATTRIBUTE; } @Override - @FXThread + @FxThread protected @NotNull String getDialogTitle() { return PluginMessages.ACTION_ADD_VERTEX_ATTRIBUTE_TITLE; } @Override - @FXThread + @FxThread protected void addParameter(@NotNull final VarTable vars) { final ShaderNodesContainer container = getContainer(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java index 6969089..456f44d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialParamShaderNodeAction.java @@ -9,7 +9,7 @@ import com.jme3.math.Vector4f; import com.jme3.shader.VarType; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -65,13 +65,13 @@ public AddMaterialParamShaderNodeAction(@NotNull final ShaderNodesContainer cont } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.MATERIAL_PARAMETER; } @Override - @FXThread + @FxThread protected void process() { super.process(); @@ -87,7 +87,7 @@ protected void process() { * * @return the list of required properties. */ - @FXThread + @FxThread protected @NotNull Array getDefinitions() { final Array varTypes = getVarTypes(); @@ -135,7 +135,7 @@ protected boolean needDefaultValue() { * * @param vars the variables. */ - @FXThread + @FxThread protected void addParam(@NotNull final VarTable vars) { final ShaderNodesContainer container = getContainer(); @@ -191,7 +191,7 @@ protected void addParam(@NotNull final VarTable vars) { * @param vars the variables. * @return true if the values are valid. */ - @FXThread + @FxThread protected boolean validate(@NotNull final VarTable vars) { final String name = vars.getString(PROP_NAME); return getObject().getMaterialParam(name) == null; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialTextureShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialTextureShaderNodeAction.java index 61b1e0f..bc5d2eb 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialTextureShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddMaterialTextureShaderNodeAction.java @@ -7,7 +7,7 @@ import com.jme3.shader.VarType; import com.jme3.texture.image.ColorSpace; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.shader.nodes.PluginMessages; @@ -50,13 +50,13 @@ protected boolean needDefaultValue() { } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.MATERIAL_TEXTURE; } @Override - @FXThread + @FxThread protected @NotNull Array getDefinitions() { final Array definitions = super.getDefinitions(); definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_COLOR_SPACE, PROP_COLOR_SPACE, ColorSpace.Linear)); @@ -76,7 +76,7 @@ protected boolean needDefaultValue() { } @Override - @FXThread + @FxThread protected void addParam(@NotNull final VarTable vars) { final ShaderNodesContainer container = getContainer(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java index a7f8d22..f8c18f5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddNodeShaderNodeAction.java @@ -8,10 +8,9 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.Editor; import com.ss.editor.FileExtensions; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ResourceManager; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -20,7 +19,8 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.add.AddShaderNodeOperation; -import com.ss.editor.ui.util.UIUtils; +import com.ss.editor.ui.util.UiUtils; +import com.ss.editor.util.EditorUtil; import com.ss.rlib.util.array.Array; import com.ss.rlib.util.array.ArrayFactory; import org.jetbrains.annotations.NotNull; @@ -34,12 +34,10 @@ */ public class AddNodeShaderNodeAction extends ShaderNodeAction { - @NotNull - private static final ResourceManager RESOURCE_MANAGER = ResourceManager.getInstance(); + public static final String PROP_DEFINITION = "definition"; @NotNull - private static final Editor EDITOR = Editor.getInstance(); - public static final String PROP_DEFINITION = "definition"; + private static final ResourceManager RESOURCE_MANAGER = ResourceManager.getInstance(); public AddNodeShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull final TechniqueDef techniqueDef, @NotNull final Vector2f location) { @@ -47,17 +45,17 @@ public AddNodeShaderNodeAction(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.SHADER_NODE; } @Override - @FXThread + @FxThread protected void process() { super.process(); final Array resources = RESOURCE_MANAGER.getAvailableResources(FileExtensions.JME_SHADER_NODE); - UIUtils.openResourceAssetDialog(this::addNode, resources); + UiUtils.openResourceAssetDialog(this::addNode, resources); } /** @@ -65,13 +63,13 @@ protected void process() { * * @param resource the selected resource. */ - @FXThread + @FxThread private void addNode(@NotNull final String resource) { final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(resource); key.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final List definitions = assetManager.loadAsset(key); if (definitions.isEmpty()) { @@ -108,7 +106,7 @@ private void addNode(@NotNull final String resource) { * * @param definition the new definition. */ - @FXThread + @FxThread private void addDefinition(final ShaderNodeDefinition definition) { final TechniqueDef techniqueDef = getObject(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddTechniqueDefParameterShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddTechniqueDefParameterShaderNodeAction.java index fb84f77..3fd101a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddTechniqueDefParameterShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddTechniqueDefParameterShaderNodeAction.java @@ -4,7 +4,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; @@ -45,7 +45,7 @@ public AddTechniqueDefParameterShaderNodeAction(@NotNull final ShaderNodesContai } @Override - @FXThread + @FxThread protected void process() { super.process(); @@ -62,7 +62,7 @@ protected void process() { * * @return the dialog title. */ - @FXThread + @FxThread protected @NotNull String getDialogTitle() { throw new RuntimeException("unsupported"); } @@ -73,7 +73,7 @@ protected void process() { * @param vars the variables. * @return true if the values are valid. */ - @FXThread + @FxThread protected boolean validate(@NotNull final VarTable vars) { return available.contains(vars.getString(PROP_NAME)); } @@ -83,6 +83,6 @@ protected boolean validate(@NotNull final VarTable vars) { * * @param vars the variables. */ - @FXThread + @FxThread protected abstract void addParameter(@NotNull final VarTable vars); } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddWorldParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddWorldParamShaderNodeAction.java index 699d041..87fcbc8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddWorldParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddWorldParamShaderNodeAction.java @@ -3,7 +3,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.add.AddWorldParameterOperation; @@ -43,19 +43,19 @@ public AddWorldParamShaderNodeAction(@NotNull final ShaderNodesContainer contain } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.WORLD_PARAMETER; } @Override - @FXThread + @FxThread protected @NotNull String getDialogTitle() { return PluginMessages.ACTION_ADD_WORLD_PARAMETER_TITLE; } @Override - @FXThread + @FxThread protected void addParameter(@NotNull final VarTable vars) { final ShaderNodesContainer container = getContainer(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java index a5aa8de..6e27f36 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java @@ -5,7 +5,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; @@ -29,13 +29,13 @@ public RemoveAttributeShaderNodeAction(@NotNull final ShaderNodesContainer conta } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java index a3a4678..db9716e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java @@ -7,7 +7,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; @@ -31,13 +31,13 @@ public RemoveMaterialParamShaderNodeAction(@NotNull final ShaderNodesContainer c } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java index 7ac2788..420eb29 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java @@ -7,7 +7,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -33,13 +33,13 @@ public RemoveRelationShaderNodeAction(@NotNull final ShaderNodesContainer contai } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java index cec95d7..aed0e3a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; @@ -31,13 +31,13 @@ public RemoveShaderNodeAction(@NotNull final ShaderNodesContainer container, @No } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java index faa8b68..a53a6a5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; @@ -30,13 +30,13 @@ public RemoveWorldParamShaderNodeAction(@NotNull final ShaderNodesContainer cont } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/GlobalShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/GlobalShaderNodeElement.java index a6b5e38..de71910 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/GlobalShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/GlobalShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; @@ -24,10 +24,14 @@ public GlobalShaderNodeElement(@NotNull final ShaderNodesContainer container, @N } @Override - @FXThread + @FxThread public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { - if (!NAMESPACE.equals(variable.getNameSpace())) return null; + + if (!NAMESPACE.equals(variable.getNameSpace())) { + return null; + } + return super.parameterFor(variable, fromOutputMapping, input); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/InputGlobalShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/InputGlobalShaderNodeElement.java index ebf90f1..29c8029 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/InputGlobalShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/InputGlobalShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; @@ -26,21 +26,25 @@ public InputGlobalShaderNodeElement(@NotNull final ShaderNodesContainer containe } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_GLOBAL_INPUT; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeParameter parameterFor(final @NotNull ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { - if (fromOutputMapping) return null; + + if (fromOutputMapping) { + return null; + } + return super.parameterFor(variable, fromOutputMapping, input); } @Override - @FXThread + @FxThread protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/OutputGlobalShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/OutputGlobalShaderNodeElement.java index bc5e699..e1698b8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/OutputGlobalShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/global/OutputGlobalShaderNodeElement.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; @@ -38,13 +38,13 @@ public OutputGlobalShaderNodeElement(@NotNull final ShaderNodesContainer contain } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_GLOBAL_OUTPUT; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeParameter parameterFor(final @NotNull ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { if (!fromOutputMapping) return null; @@ -52,7 +52,7 @@ public OutputGlobalShaderNodeElement(@NotNull final ShaderNodesContainer contain } @Override - @FXThread + @FxThread protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); @@ -68,7 +68,7 @@ protected void fillParameters(@NotNull final VBox container) { } @Override - @FXThread + @FxThread public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { @@ -89,7 +89,7 @@ public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, } @Override - @FXThread + @FxThread public void attach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { super.attach(inputParameter, outputParameter); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/TempLine.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/TempLine.java index bb38898..b548948 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/TempLine.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/TempLine.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.line; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_TEMP_LINE; -import com.ss.editor.annotation.FXThread; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_TEMP_LINE; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import javafx.scene.shape.CubicCurve; import javafx.scene.shape.StrokeLineCap; @@ -26,7 +26,7 @@ public TempLine(@NotNull final SocketElement sourceSocket) { /** * Configure the line. */ - @FXThread + @FxThread private void configureLine() { startXProperty().bind(sourceSocket.centerXPropertyProperty()); startYProperty().bind(sourceSocket.centerYPropertyProperty()); @@ -44,7 +44,7 @@ private void configureLine() { * @param x the X coord. * @param y the Y coord. */ - @FXThread + @FxThread public void updateEnd(final double x, final double y) { setEndX(x); setEndY(y); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java index c42179a..75dd89e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.line; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_LINE; -import com.ss.editor.annotation.FXThread; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_LINE; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; @@ -38,7 +38,7 @@ public VariableLine(@NotNull final ShaderNodeParameter outParameter, * * @param event the menu requested event. */ - @FXThread + @FxThread private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { final ShaderNodeElement nodeElement = inParameter.getNodeElement(); final ShaderNodesContainer container = nodeElement.getContainer(); @@ -51,7 +51,7 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { * * @return the input parameter. */ - @FXThread + @FxThread public @NotNull ShaderNodeParameter getInParameter() { return inParameter; } @@ -61,7 +61,7 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { * * @return the output parameter. */ - @FXThread + @FxThread public @NotNull ShaderNodeParameter getOutParameter() { return outParameter; } @@ -69,7 +69,7 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { /** * Configure the line. */ - @FXThread + @FxThread private void configureLine() { final SocketElement outSocket = outParameter.getSocket(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/AttributeShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/AttributeShaderNodeElement.java index 417b94c..b7ea9f2 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/AttributeShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/AttributeShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -26,19 +26,19 @@ public AttributeShaderNodeElement(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_VERTEX_ATTRIBUTE; } @Override - @FXThread + @FxThread protected @NotNull String getNameSpace() { return NAMESPACE; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return new RemoveAttributeShaderNodeAction(getContainer(), getObject(), new Vector2f((float) getLayoutX(), (float) getLayoutY())); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/FragmentShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/FragmentShaderNodeElement.java index 6de68a2..7696060 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/FragmentShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/FragmentShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.ShaderNode; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.InputGlobalShaderNodeElement; @@ -22,7 +22,7 @@ public FragmentShaderNodeElement(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java index d8bf0bc..a5fe69c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java @@ -4,7 +4,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.*; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -41,18 +41,18 @@ public MainShaderNodeElement(@NotNull final ShaderNodesContainer container, @Not } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return getObject().getDefinition().getName(); } @Override - @FXThread + @FxThread protected @NotNull Optional createTooltip() { return Optional.of(new SndDocumentationTooltip(getObject().getDefinition())); } - @FXThread + @FxThread @Override public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { @@ -65,7 +65,7 @@ public MainShaderNodeElement(@NotNull final ShaderNodesContainer container, @Not return super.parameterFor(variable, fromOutputMapping, input); } - @FXThread + @FxThread @Override protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); @@ -85,7 +85,7 @@ protected void fillParameters(@NotNull final VBox container) { } @Override - @FXThread + @FxThread public void attach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { super.attach(inputParameter, outputParameter); @@ -145,7 +145,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, } @Override - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return new RemoveShaderNodeAction(getContainer(), getObject(), new Vector2f((float) getLayoutX(), (float) getLayoutY())); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java index a1dcb10..a20064c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java @@ -9,17 +9,16 @@ import com.jme3.math.Vector4f; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VarType; -import com.ss.editor.annotation.FXThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.PluginMessages; +import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.remove.RemoveMaterialParamShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.EditableMaterialShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; -import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.editor.ui.control.property.PropertyControl; import com.ss.editor.ui.control.property.impl.*; import org.jetbrains.annotations.NotNull; @@ -56,7 +55,7 @@ public MaterialShaderNodeElement(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread protected @NotNull OutputShaderNodeParameter newParameter() { final ShaderNodeVariable variable = getObject(); @@ -88,7 +87,7 @@ public MaterialShaderNodeElement(@NotNull final ShaderNodesContainer container, /** * Notify about changed preview material. */ - @FXThread + @FxThread public void notifyChangedMaterial() { getParametersContainer().getChildren().stream() .filter(EditableMaterialShaderNodeParameter.class::isInstance) @@ -96,7 +95,7 @@ public void notifyChangedMaterial() { .forEach(EditableMaterialShaderNodeParameter::sync); } - @FXThread + @FxThread private @Nullable PropertyControl buildControl(@NotNull final ChangeConsumer consumer, @NotNull final MatParam param) { @@ -138,7 +137,7 @@ public void notifyChangedMaterial() { return null; } - @FXThread + @FxThread private T getCurrentValue(@NotNull final MatParam matParam) { final ShaderNodesChangeConsumer changeConsumer = getContainer().getChangeConsumer(); @@ -159,7 +158,7 @@ private T getCurrentValue(@NotNull final MatParam matParam) { return value; } - @JMEThread + @FxThread private void applyValue(@NotNull final MatParam matParam, @Nullable T value) { final ShaderNodesChangeConsumer changeConsumer = getContainer().getChangeConsumer(); @@ -177,19 +176,19 @@ private void applyValue(@NotNull final MatParam matParam, @Nullable T value) } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_MATERIAL_PARAMETER; } @Override - @FXThread + @FxThread protected @NotNull String getNameSpace() { return NAMESPACE; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return new RemoveMaterialParamShaderNodeAction(getContainer(), getObject(), new Vector2f((float) getLayoutX(), (float) getLayoutY())); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/OutputVariableShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/OutputVariableShaderNodeElement.java index b92f54f..3c406a9 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/OutputVariableShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/OutputVariableShaderNodeElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.main; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; import com.ss.rlib.ui.util.FXUtils; @@ -21,7 +21,7 @@ public OutputVariableShaderNodeElement(@NotNull final ShaderNodesContainer conta } @Override - @FXThread + @FxThread protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); FXUtils.addToPane(newParameter(), container); @@ -32,7 +32,7 @@ protected void fillParameters(@NotNull final VBox container) { * * @return the output parameter. */ - @FXThread + @FxThread protected @NotNull OutputShaderNodeParameter newParameter() { return new OutputShaderNodeParameter(this, getObject()); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VariableShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VariableShaderNodeElement.java index 7e14527..46de34e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VariableShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VariableShaderNodeElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.main; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; @@ -20,11 +20,15 @@ public VariableShaderNodeElement(@NotNull final ShaderNodesContainer container, super(container, variable); } - @FXThread + @FxThread @Override public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { - if (!getNameSpace().equals(variable.getNameSpace())) return null; + + if (!getNameSpace().equals(variable.getNameSpace())) { + return null; + } + return super.parameterFor(variable, fromOutputMapping, input); } @@ -33,7 +37,7 @@ public VariableShaderNodeElement(@NotNull final ShaderNodesContainer container, * * @return the namespace. */ - @FXThread + @FxThread protected @NotNull String getNameSpace() { return "unknown"; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VertexShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VertexShaderNodeElement.java index 5245083..e21d50e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VertexShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/VertexShaderNodeElement.java @@ -2,7 +2,7 @@ import com.jme3.material.ShaderGenerationInfo; import com.jme3.shader.ShaderNode; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.InputGlobalShaderNodeElement; @@ -22,7 +22,7 @@ public VertexShaderNodeElement(@NotNull final ShaderNodesContainer container, @N } @Override - @FXThread + @FxThread public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/WorldShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/WorldShaderNodeElement.java index 144f8ec..3d2e9d3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/WorldShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/WorldShaderNodeElement.java @@ -3,7 +3,7 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; @@ -38,19 +38,19 @@ public WorldShaderNodeElement(@NotNull final ShaderNodesContainer container, } @Override - @FXThread + @FxThread protected @NotNull String getTitleText() { return PluginMessages.NODE_ELEMENT_WORLD_PARAMETER; } @Override - @FXThread + @FxThread protected @NotNull String getNameSpace() { return NAMESPACE; } @Override - @FXThread + @FxThread public @Nullable ShaderNodeAction getDeleteAction() { return new RemoveWorldParamShaderNodeAction(getContainer(), getObject(), new Vector2f((float) getLayoutX(), (float) getLayoutY())); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java index 1f9d17c..fc7fc3f 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ChangeLightModeOperation.java @@ -4,7 +4,7 @@ import com.jme3.material.TechniqueDef; import com.jme3.material.logic.*; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,9 +39,9 @@ public ChangeLightModeOperation(@NotNull final String techniqueName, } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); final MaterialDef materialDef = editor.getMaterialDef(); final List techniqueDefs = materialDef.getTechniqueDefs(techniqueName); @@ -55,13 +55,13 @@ protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito createLogic(techniqueDef); - editor.notifyFXChangeProperty(techniqueDef, Messages.MODEL_PROPERTY_LIGHT_MODE); + editor.notifyFxChangeProperty(techniqueDef, Messages.MODEL_PROPERTY_LIGHT_MODE); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); final MaterialDef materialDef = editor.getMaterialDef(); final List techniqueDefs = materialDef.getTechniqueDefs(techniqueName); @@ -75,7 +75,7 @@ protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito createLogic(techniqueDef); - editor.notifyFXChangeProperty(techniqueDef, Messages.MODEL_PROPERTY_LIGHT_MODE); + editor.notifyFxChangeProperty(techniqueDef, Messages.MODEL_PROPERTY_LIGHT_MODE); } /** @@ -83,7 +83,7 @@ protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito * * @param techniqueDef the technique def. */ - @FXThread + @FxThread private void createLogic(@NotNull final TechniqueDef techniqueDef) { switch (techniqueDef.getLightMode()) { case SinglePass: { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ShaderNodeOperation.java index 58fba92..f0af465 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/ShaderNodeOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.operation; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -14,40 +14,40 @@ public class ShaderNodeOperation extends AbstractEditorOperation { @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ShaderNodesChangeConsumer editor) { - EXECUTOR_MANAGER.addJMETask(() -> { - redoImplInJMEThread(editor); - EXECUTOR_MANAGER.addFXTask(() -> redoImplInFXThread(editor)); + EXECUTOR_MANAGER.addJmeTask(() -> { + redoImplInJmeThread(editor); + EXECUTOR_MANAGER.addFxTask(() -> redoImplInFxThread(editor)); }); } - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { } - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ShaderNodesChangeConsumer editor) { - EXECUTOR_MANAGER.addJMETask(() -> { - undoImplInJMEThread(editor); - EXECUTOR_MANAGER.addFXTask(() -> undoImplInFXThread(editor)); + EXECUTOR_MANAGER.addJmeTask(() -> { + undoImplInJmeThread(editor); + EXECUTOR_MANAGER.addFxTask(() -> undoImplInFxThread(editor)); }); } - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { } - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddAttributeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddAttributeOperation.java index 41520c9..09b41a8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddAttributeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddAttributeOperation.java @@ -4,8 +4,8 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -45,34 +45,34 @@ public AddAttributeOperation(@NotNull final TechniqueDef techniqueDef, @NotNull } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); final List attributes = generationInfo.getAttributes(); attributes.add(variable); } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyAddedAttribute(variable, location); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); final List attributes = generationInfo.getAttributes(); attributes.remove(variable); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyRemovedAttribute(variable); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddMaterialParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddMaterialParameterOperation.java index da38a49..1c25f6d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddMaterialParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddMaterialParameterOperation.java @@ -4,8 +4,8 @@ import com.jme3.material.MatParam; import com.jme3.material.MaterialDef; import com.jme3.math.Vector2f; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -45,35 +45,35 @@ public AddMaterialParameterOperation(@NotNull final MaterialDef materialDef, @No } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final Map matParams = getMatParams(materialDef); matParams.put(matParam.getName(), matParam); } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyAddedMatParameter(matParam, location); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final Map matParams = getMatParams(materialDef); matParams.remove(matParam.getName()); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyRemovedMatParameter(matParam); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddShaderNodeOperation.java index fba8bab..40c3155 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddShaderNodeOperation.java @@ -5,8 +5,8 @@ import com.jme3.math.Vector2f; import com.jme3.shader.Shader; import com.jme3.shader.ShaderNode; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -54,9 +54,9 @@ public AddShaderNodeOperation(@NotNull final TechniqueDef techniqueDef, @NotNull } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final List shaderNodes = techniqueDef.getShaderNodes(); previousShaderNodes = new ArrayList<>(shaderNodes); @@ -83,16 +83,16 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyAddedShaderNode(shaderNode, location); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final List shaderNodes = techniqueDef.getShaderNodes(); shaderNodes.clear(); shaderNodes.addAll(previousShaderNodes); @@ -100,9 +100,9 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyRemovedRemovedShaderNode(shaderNode); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddTechniqueOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddTechniqueOperation.java index ac1e237..e1160d1 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddTechniqueOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddTechniqueOperation.java @@ -2,8 +2,8 @@ import com.jme3.material.MaterialDef; import com.jme3.material.TechniqueDef; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -35,32 +35,32 @@ public AddTechniqueOperation(@NotNull final MaterialDef materialDef, @NotNull fi } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); materialDef.addTechniqueDef(techniqueDef); } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyAddedTechnique(techniqueDef); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final List techniqueDefs = materialDef.getTechniqueDefs(techniqueDef.getName()); techniqueDefs.remove(techniqueDef); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyRemovedTechnique(techniqueDef); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddWorldParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddWorldParameterOperation.java index b2829f7..a734723 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddWorldParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/add/AddWorldParameterOperation.java @@ -3,8 +3,8 @@ import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -42,30 +42,30 @@ public AddWorldParameterOperation(@NotNull final TechniqueDef techniqueDef, @Not } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); techniqueDef.getWorldBindings().add(binding); } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyAddedWorldParameter(binding, location); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); techniqueDef.getWorldBindings().remove(binding); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyRemovedWorldParameter(binding); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachAttributeToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachAttributeToShaderNodeOperation.java index 15382d6..58c892e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachAttributeToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachAttributeToShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,9 +23,9 @@ public AttachAttributeToShaderNodeOperation(@NotNull final ShaderNode shaderNode } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final List inputMapping = getShaderNode().getInputMapping(); @@ -39,9 +39,9 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final List inputMapping = getShaderNode().getInputMapping(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachGlobalToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachGlobalToShaderNodeOperation.java index 7681689..400101a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachGlobalToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachGlobalToShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,9 +23,9 @@ public AttachGlobalToShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final List inputMapping = getShaderNode().getInputMapping(); @@ -39,9 +39,9 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final List inputMapping = getShaderNode().getInputMapping(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java index cfcc415..d5d716d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; @@ -73,20 +73,20 @@ protected AttachShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); notify(editor, oldMapping, newMapping); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); notify(editor, newMapping, oldMapping); } - @FXThread + @FxThread protected void notify(@NotNull final ShaderNodesChangeConsumer editor, @Nullable final VariableMapping oldMapping, @Nullable final VariableMapping newMapping) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachUniformToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachUniformToShaderNodeOperation.java index 2abbf1c..bc9f6df 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachUniformToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachUniformToShaderNodeOperation.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,9 +48,9 @@ public AttachUniformToShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final ShaderNode shaderNode = getShaderNode(); final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); @@ -79,9 +79,9 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final ShaderNode shaderNode = getShaderNode(); final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToGlobalNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToGlobalNodeOperation.java index 9b6997b..f6f5dc4 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToGlobalNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToGlobalNodeOperation.java @@ -7,7 +7,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -69,9 +69,9 @@ public AttachVarToGlobalNodeOperation(@NotNull final TechniqueDef techniqueDef, } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final List outputMapping = getShaderNode().getOutputMapping(); final TechniqueDef techniqueDef = getTechniqueDef(); @@ -143,9 +143,9 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final TechniqueDef techniqueDef = getTechniqueDef(); final ShaderGenerationInfo info = techniqueDef.getShaderGenerationInfo(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java index 1ba8ffa..0d74c55 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java @@ -8,7 +8,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -68,9 +68,9 @@ public AttachVarToShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final ShaderNode shaderNode = getShaderNode(); final Shader.ShaderType inType = shaderNode.getDefinition().getType(); @@ -125,9 +125,9 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final VariableMapping newMapping = getNewMapping(); final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/DetachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/DetachShaderNodeOperation.java index 22f1863..4cdd24e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/DetachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/DetachShaderNodeOperation.java @@ -2,9 +2,9 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -58,16 +58,16 @@ protected DetachShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); getMappings().remove(oldMapping); } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyRemovedMapping(shaderNode, oldMapping); } @@ -76,22 +76,22 @@ protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer edito * * @return the mapping list. */ - @JMEThread + @JmeThread protected @NotNull List getMappings() { throw new RuntimeException(); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); getMappings().add(oldMapping); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyAddedMapping(shaderNode, oldMapping); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/InputDetachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/InputDetachShaderNodeOperation.java index b0a583c..f944876 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/InputDetachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/InputDetachShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -20,7 +20,7 @@ public InputDetachShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread + @JmeThread protected @NotNull List getMappings() { return getShaderNode().getInputMapping(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/OutputDetachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/OutputDetachShaderNodeOperation.java index 91bf3b8..42b500f 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/OutputDetachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/detach/OutputDetachShaderNodeOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -20,7 +20,7 @@ public OutputDetachShaderNodeOperation(@NotNull final ShaderNode shaderNode, } @Override - @JMEThread + @JmeThread protected @NotNull List getMappings() { return getShaderNode().getOutputMapping(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveAttributeVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveAttributeVariableOperation.java index 5d2fb69..ad5d06c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveAttributeVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveAttributeVariableOperation.java @@ -5,8 +5,8 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -26,34 +26,34 @@ public RemoveAttributeVariableOperation(@NotNull final List shaderNo } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final ShaderGenerationInfo info = techniqueDef.getShaderGenerationInfo(); info.getAttributes().remove(variable); } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyRemovedAttribute(variable); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final ShaderGenerationInfo info = techniqueDef.getShaderGenerationInfo(); info.getAttributes().add(variable); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyAddedAttribute(variable, location); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveMaterialParameterVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveMaterialParameterVariableOperation.java index 19fed38..32e7834 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveMaterialParameterVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveMaterialParameterVariableOperation.java @@ -7,8 +7,8 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -45,34 +45,34 @@ public RemoveMaterialParameterVariableOperation(@NotNull final List } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final Map matParams = getMatParams(materialDef); matParams.remove(matParam.getName()); } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyRemovedMatParameter(matParam); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final Map matParams = getMatParams(materialDef); matParams.put(matParam.getName(), matParam); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyAddedMatParameter(matParam, location); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveShaderNodeOperation.java index 2f91534..ba39731 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveShaderNodeOperation.java @@ -7,8 +7,8 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -41,9 +41,9 @@ public RemoveShaderNodeOperation(@NotNull final List shaderNodes, @N } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); for (final ShaderNode otherNode : shaderNodes) { @@ -67,16 +67,16 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyRemovedRemovedShaderNode(shaderNode); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); for (final Map.Entry> entry : toRestore.entrySet()) { final ShaderNode shaderNode = entry.getKey(); @@ -90,9 +90,9 @@ protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyAddedShaderNode(shaderNode, location); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveUniformVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveUniformVariableOperation.java index 622f890..2c8bef2 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveUniformVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveUniformVariableOperation.java @@ -5,7 +5,7 @@ import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,9 +38,9 @@ public RemoveUniformVariableOperation(@NotNull final List shaderNode } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); final ShaderGenerationInfo info = techniqueDef.getShaderGenerationInfo(); final List vertexUniforms = info.getVertexUniforms(); @@ -56,9 +56,9 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); final ShaderGenerationInfo info = techniqueDef.getShaderGenerationInfo(); final List vertexUniforms = info.getVertexUniforms(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveVariableOperation.java index 18da95c..6fe56ea 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveVariableOperation.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -33,9 +33,9 @@ public RemoveVariableOperation(@NotNull final List shaderNodes, @Not } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); for (final ShaderNode shaderNode : shaderNodes) { final List mappings = findInMappingsByNNRightVar(shaderNode, variable); @@ -47,9 +47,9 @@ protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer edit } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); for (final Map.Entry> entry : toRestore.entrySet()) { final ShaderNode shaderNode = entry.getKey(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveWorldParameterVariableOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveWorldParameterVariableOperation.java index bf76c06..be8a7b7 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveWorldParameterVariableOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/remove/RemoveWorldParameterVariableOperation.java @@ -5,8 +5,8 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; -import com.ss.editor.annotation.FXThread; -import com.ss.editor.annotation.JMEThread; +import com.ss.editor.annotation.FxThread; +import com.ss.editor.annotation.JmeThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import org.jetbrains.annotations.NotNull; @@ -34,30 +34,30 @@ public RemoveWorldParameterVariableOperation(@NotNull final List sha } @Override - @JMEThread - protected void redoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInJMEThread(editor); + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); techniqueDef.getWorldBindings().remove(binding); } @Override - @FXThread - protected void redoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.redoImplInFXThread(editor); + @FxThread + protected void redoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInFxThread(editor); editor.notifyRemovedWorldParameter(binding); } @Override - @JMEThread - protected void undoImplInJMEThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInJMEThread(editor); + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); techniqueDef.getWorldBindings().add(binding); } @Override - @FXThread - protected void undoImplInFXThread(@NotNull final ShaderNodesChangeConsumer editor) { - super.undoImplInFXThread(editor); + @FxThread + protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInFxThread(editor); editor.notifyAddedWorldParameter(binding, location); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java index 6dfd6be..1d23261 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java @@ -1,9 +1,9 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_MATERIAL_OUTPUT_PARAMETER; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_MATERIAL_OUTPUT_PARAMETER; import com.jme3.material.MatParam; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MaterialShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.OutputSocketElement; @@ -41,19 +41,19 @@ public EditableMaterialShaderNodeParameter(@NotNull final MaterialShaderNodeElem /** * Sync the current value of this parameter. */ - @FXThread + @FxThread public void sync() { propertyControl.sync(); } @Override - @FXThread + @FxThread protected @NotNull SocketElement createSocket() { return new OutputSocketElement(this); } @Override - @FXThread + @FxThread protected void createContent() { } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index 88e3623..13162a7 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -1,8 +1,8 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_INPUT_PARAMETER; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_INPUT_PARAMETER; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.InputSocketElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; @@ -23,13 +23,13 @@ public InputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, } @Override - @FXThread + @FxThread protected @NotNull SocketElement createSocket() { return new InputSocketElement(this); } @Override - @FXThread + @FxThread protected void createContent() { super.createContent(); FXUtils.addToPane(getSocket(), this); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java index 206abb3..81a7ca1 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java @@ -1,8 +1,8 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_OUTPUT_PARAMETER; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_OUTPUT_PARAMETER; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.OutputSocketElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; @@ -23,13 +23,13 @@ public OutputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement } @Override - @FXThread + @FxThread protected @NotNull SocketElement createSocket() { return new OutputSocketElement(this); } @Override - @FXThread + @FxThread protected void createContent() { super.createContent(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java index bc8a62b..de3f0a1 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java @@ -1,9 +1,9 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_PARAMETER; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_PARAMETER_SOCKET; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_PARAMETER; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_PARAMETER_SOCKET; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import com.ss.rlib.ui.util.FXUtils; @@ -65,7 +65,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, * * @return the shader nodes element. */ - @FXThread + @FxThread public @NotNull ShaderNodeElement getNodeElement() { return nodeElement; } @@ -75,7 +75,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, * * @return the socket element. */ - @FXThread + @FxThread protected @NotNull SocketElement createSocket() { return new SocketElement(this); } @@ -83,7 +83,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * @return the type label. */ - @FXThread + @FxThread protected @NotNull Label getTypeLabel() { return typeLabel; } @@ -91,7 +91,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * @return the name label. */ - @FXThread + @FxThread protected @NotNull Label getNameLabel() { return nameLabel; } @@ -99,7 +99,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * @return the socket. */ - @FXThread + @FxThread public @NotNull SocketElement getSocket() { return socket; } @@ -107,7 +107,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * @return the variable. */ - @FXThread + @FxThread public @NotNull ShaderNodeVariable getVariable() { return variable; } @@ -115,7 +115,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * Create content of this parameter. */ - @FXThread + @FxThread protected void createContent() { final ShaderNodeVariable variable = getVariable(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java index c1f11b4..399fa16 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_PARAMETER_INPUT_SOCKET; -import com.ss.editor.annotation.FXThread; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_PARAMETER_INPUT_SOCKET; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.InputShaderNodeParameter; @@ -88,7 +88,7 @@ public InputSocketElement(@NotNull final ShaderNodeParameter parameter) { * * @param dragEvent the drag event. */ - @FXThread + @FxThread private void handleDragExited(@NotNull final DragEvent dragEvent) { droppable.setValue(false); } @@ -98,7 +98,7 @@ private void handleDragExited(@NotNull final DragEvent dragEvent) { * * @param dragEvent the drag event. */ - @FXThread + @FxThread private void handleDragDropped(@NotNull final DragEvent dragEvent) { droppable.setValue(false); @@ -125,7 +125,7 @@ private void handleDragDropped(@NotNull final DragEvent dragEvent) { * * @param dragEvent the drag event. */ - @FXThread + @FxThread private void handleDragOver(@NotNull final DragEvent dragEvent) { final InputShaderNodeParameter parameter = (InputShaderNodeParameter) getParameter(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java index 37eacef..f5243d5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket; -import static com.ss.editor.shader.nodes.ui.PluginCSSClasses.SHADER_NODE_PARAMETER_OUTPUT_SOCKET; -import com.ss.editor.annotation.FXThread; +import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_PARAMETER_OUTPUT_SOCKET; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; @@ -61,7 +61,7 @@ public OutputSocketElement(@NotNull final ShaderNodeParameter parameter) { * * @param mouseEvent the mouse event. */ - @FXThread + @FxThread private void handleMouseDragged(final MouseEvent mouseEvent) { final ShaderNodeParameter parameter = getParameter(); final ShaderNodeElement nodeElement = parameter.getNodeElement(); @@ -76,7 +76,7 @@ private void handleMouseDragged(final MouseEvent mouseEvent) { * * @param dragEvent the drag event. */ - @FXThread + @FxThread private void handleStopDrag(@NotNull final DragEvent dragEvent) { setCursor(Cursor.DEFAULT); @@ -94,7 +94,7 @@ private void handleStopDrag(@NotNull final DragEvent dragEvent) { * * @param mouseEvent the mouse event. */ - @FXThread + @FxThread private void handleStartDrag(@NotNull final MouseEvent mouseEvent) { setCursor(Cursor.MOVE); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java index d9409e5..55e0aac 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; import javafx.beans.property.DoubleProperty; @@ -53,7 +53,7 @@ public SocketElement(@NotNull final ShaderNodeParameter parameter) { * * @return the nodes parameter element. */ - @FXThread + @FxThread protected @NotNull ShaderNodeParameter getParameter() { return parameter; } @@ -65,7 +65,7 @@ public SocketElement(@NotNull final ShaderNodeParameter parameter) { * @param oldValue the old value. * @param newValue the new value. */ - @FXThread + @FxThread private void updateCenterCoords(@Nullable final ObservableValue observable, @Nullable final Number oldValue, @Nullable final Number newValue) { @@ -87,7 +87,7 @@ private void updateCenterCoords(@Nullable final ObservableValue { - @NotNull - private static final Editor EDITOR = Editor.getInstance(); - @NotNull private final ShaderNodeDefinition definition; @@ -36,19 +33,19 @@ public SndDocumentationTooltip(@NotNull final ShaderNodeDefinition definition) { } @Override - @FXThread + @FxThread protected @NotNull BorderPane createRoot() { return new BorderPane(); } @Override - @FXThread + @FxThread protected void createContent(@NotNull final BorderPane root) { super.createContent(root); this.documentation = new SndDocumentationArea(); this.documentation.setEditable(false); root.setCenter(documentation); - FXUtils.addClassesTo(documentation, PluginCSSClasses.SHADER_NODE_DEF_DOCUMENTATION_TOOLTIP); + FXUtils.addClassesTo(documentation, PluginCssClasses.SHADER_NODE_DEF_DOCUMENTATION_TOOLTIP); } /** @@ -56,7 +53,7 @@ protected void createContent(@NotNull final BorderPane root) { * * @return the definition. */ - @FXThread + @FxThread private @NotNull ShaderNodeDefinition getDefinition() { return definition; } @@ -66,20 +63,20 @@ protected void createContent(@NotNull final BorderPane root) { * * @return the area to show documentation. */ - @FXThread + @FxThread private @NotNull SndDocumentationArea getDocumentation() { return notNull(documentation); } @Override - @FXThread + @FxThread protected void show() { final ShaderNodeDefinition definition = getDefinition(); final ShaderNodeDefinitionKey assetKey = new ShaderNodeDefinitionKey(definition.getPath()); assetKey.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); String documentation = assetManager.loadAsset(assetKey).stream() .filter(def -> def.getName().equals(definition.getName())) .map(ShaderNodeDefinition::getDocumentation) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java index 072f0c9..063828b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java @@ -7,7 +7,7 @@ import com.jme3.shader.Shader.ShaderType; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -45,19 +45,19 @@ public AddSndAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.ACTION_ADD_SHADER_NODE_DEFINITION; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.ADD_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); @@ -76,7 +76,7 @@ protected void process() { * * @param vars the vars of the definition. */ - @FXThread + @FxThread private boolean validate(@NotNull final VarTable vars) { final String name = vars.getString(PROP_NAME); @@ -93,7 +93,7 @@ private boolean validate(@NotNull final VarTable vars) { * * @param vars the vars of the definition. */ - @FXThread + @FxThread private void addDefinition(@NotNull final VarTable vars) { final String definitionName = vars.getString(PROP_NAME); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java index 70f9a2c..d468d6a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -22,13 +22,13 @@ public AddSndInputParameterAction(@NotNull final NodeTree nodeTree, } @Override - @FXThread + @FxThread protected @NotNull List getCurrentParameters(@NotNull final ShaderNodeDefinition definition) { return definition.getInputs(); } @Override - @FXThread + @FxThread protected @NotNull List getOppositeParameters(@NotNull final ShaderNodeDefinition definition) { return definition.getOutputs(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java index 2495344..adc1a7f 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import org.jetbrains.annotations.NotNull; @@ -22,13 +22,13 @@ public AddSndOutputParameterAction(@NotNull final NodeTree nodeTree, } @Override - @FXThread + @FxThread protected @NotNull List getCurrentParameters(@NotNull final ShaderNodeDefinition definition) { return definition.getOutputs(); } @Override - @FXThread + @FxThread protected @NotNull List getOppositeParameters(@NotNull final ShaderNodeDefinition definition) { return definition.getInputs(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java index c5c5995..22cb6fb 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java @@ -6,7 +6,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -17,7 +17,7 @@ import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.action.AbstractNodeAction; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.editor.util.GLSLType; +import com.ss.editor.util.GlslType; import com.ss.rlib.util.StringUtils; import com.ss.rlib.util.VarTable; import com.ss.rlib.util.array.Array; @@ -47,13 +47,13 @@ public AddSndParameterAction(@NotNull final NodeTree nodeTree, @NotNull final } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.ACTION_ADD_SND_PARAMETER; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.ADD_16; } @@ -64,7 +64,7 @@ public AddSndParameterAction(@NotNull final NodeTree nodeTree, @NotNull final * @param definition the definition. * @return the list of current parameters. */ - @FXThread + @FxThread protected abstract @NotNull List getCurrentParameters( @NotNull final ShaderNodeDefinition definition); @@ -74,18 +74,18 @@ public AddSndParameterAction(@NotNull final NodeTree nodeTree, @NotNull final * @param definition the definition. * @return the list of opposite parameters. */ - @FXThread + @FxThread protected abstract @NotNull List getOppositeParameters( @NotNull final ShaderNodeDefinition definition); @Override - @FXThread + @FxThread protected void process() { super.process(); final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(STRING, Messages.MODEL_PROPERTY_NAME, PROP_NAME, "newVar")); - definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_TYPE, PROP_TYPE, GLSLType.FLOAT)); + definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_TYPE, PROP_TYPE, GlslType.FLOAT)); final GenericFactoryDialog dialog = new GenericFactoryDialog(definitions, this::addParameter, this::validate); dialog.setTitle(getName()); @@ -97,7 +97,7 @@ protected void process() { * * @param vars the vars of the new parameter. */ - @FXThread + @FxThread private boolean validate(@NotNull final VarTable vars) { final TreeNode node = getNode(); @@ -112,8 +112,8 @@ private boolean validate(@NotNull final VarTable vars) { return false; } - final GLSLType glslType = vars.getEnum(PROP_TYPE, GLSLType.class); - final String rawType = glslType.getRawType(); + final GlslType GlslType = vars.getEnum(PROP_TYPE, GlslType.class); + final String rawType = GlslType.getRawType(); final List oppositeParameters = getOppositeParameters(definition); final Optional oppositeParameter = oppositeParameters.stream() @@ -133,16 +133,16 @@ private boolean validate(@NotNull final VarTable vars) { * * @param vars the vars of the parameter. */ - @FXThread + @FxThread private void addParameter(@NotNull final VarTable vars) { final TreeNode node = getNode(); final SndParameters parameters = (SndParameters) node.getElement(); final String name = vars.getString(PROP_NAME); - final GLSLType glslType = vars.getEnum(PROP_TYPE, GLSLType.class); + final GlslType GlslType = vars.getEnum(PROP_TYPE, GlslType.class); - final ShaderNodeVariable variable = new ShaderNodeVariable(glslType.getRawType(), name); + final ShaderNodeVariable variable = new ShaderNodeVariable(GlslType.getRawType(), name); final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer()); changeConsumer.execute(new AddSndParameterOperation(parameters, variable)); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java index b5f2ba0..bce7498 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java @@ -8,7 +8,7 @@ import com.jme3.renderer.Caps; import com.jme3.shader.Shader; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; import com.ss.editor.plugin.api.property.PropertyDefinition; @@ -47,19 +47,19 @@ public AddSndShaderSourceAction(@NotNull final NodeTree nodeTree, @NotNull fi } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.ACTION_ADD_SHADER_NODE_SOURCE; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.ADD_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); @@ -84,7 +84,7 @@ protected void process() { * * @param vars the vars of the definition. */ - @FXThread + @FxThread private boolean validate(@NotNull final VarTable vars) { if (!vars.has(PROP_SHADER_RESOURCE)) { @@ -106,7 +106,7 @@ private boolean validate(@NotNull final VarTable vars) { * * @param vars the vars of the source. */ - @FXThread + @FxThread private void addShaderSource(@NotNull final VarTable vars) { final String language = vars.getString(PROP_LANGUAGE); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java index ba40165..a12a967 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; import com.ss.editor.shader.nodes.ui.control.tree.operation.DeleteSndOperation; @@ -27,19 +27,19 @@ public DeleteSndAction(@NotNull final NodeTree nodeTree, @NotNull final TreeN } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.REMOVE_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java index 8b76401..52bccd4 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java @@ -2,7 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSources; @@ -27,19 +27,19 @@ public DeleteSndShaderSourceAction(@NotNull final NodeTree nodeTree, @NotNull } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.REMOVE_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java index e023408..5fba766 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java @@ -3,7 +3,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; import com.ss.editor.shader.nodes.ui.control.tree.operation.DeleteSndParameterOperation; @@ -27,19 +27,19 @@ public DeleteSndarameterAction(@NotNull final NodeTree nodeTree, @NotNull fin } @Override - @FXThread + @FxThread protected @NotNull String getName() { return Messages.MODEL_NODE_TREE_ACTION_REMOVE; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.REMOVE_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java index 7dfddf8..80c541c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java @@ -2,7 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndDocumentation; @@ -28,19 +28,19 @@ public EditSndDocumentationAction(@NotNull final NodeTree nodeTree, @NotNull } @Override - @FXThread + @FxThread protected @NotNull String getName() { return PluginMessages.ACTION_ADD_EDIT_DOCUMENTATION; } @Override - @FXThread + @FxThread protected @Nullable Image getIcon() { return Icons.EDIT_16; } @Override - @FXThread + @FxThread protected void process() { super.process(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java index 8efcb79..fb34725 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java @@ -3,14 +3,14 @@ import static com.ss.rlib.util.ClassUtils.unsafeCast; import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.model.PreviewMaterialSettings; import com.ss.editor.shader.nodes.model.shader.node.definition.*; import com.ss.editor.shader.nodes.ui.control.tree.node.PreviewMaterialSettingsTreeNode; import com.ss.editor.shader.nodes.ui.control.tree.node.definition.*; import com.ss.editor.ui.control.tree.node.TreeNode; -import com.ss.editor.ui.control.tree.node.TreeNodeFactory; +import com.ss.editor.ui.control.tree.node.factory.TreeNodeFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,7 +29,7 @@ public class ShaderNodesTreeNodeFactory implements TreeNodeFactory { } @Override - @FXThread + @FxThread public > @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof PreviewMaterialSettings) { @@ -56,8 +56,8 @@ public class ShaderNodesTreeNodeFactory implements TreeNodeFactory { } @Override - @FXThread - public int getOrder() { + @FxThread + public int getPriority() { return 5; } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/PreviewMaterialSettingsTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/PreviewMaterialSettingsTreeNode.java index d9d1999..2687b99 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/PreviewMaterialSettingsTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/PreviewMaterialSettingsTreeNode.java @@ -2,7 +2,7 @@ import com.ss.editor.model.node.material.RootMaterialSettings; import com.ss.editor.shader.nodes.PluginMessages; -import com.ss.editor.ui.control.material.tree.node.RootMaterialSettingsTreeNode; +import com.ss.editor.ui.control.tree.node.impl.material.settings.RootMaterialSettingsTreeNode; import org.jetbrains.annotations.NotNull; /** diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndDocumentationTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndDocumentationTreeNode.java index 49f35a9..82293f8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndDocumentationTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndDocumentationTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndDocumentation; @@ -26,14 +26,14 @@ public SndDocumentationTreeNode(@NotNull final SndDocumentation element, final l } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new EditSndDocumentationAction(nodeTree, this)); } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.DOCUMENT_16; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndListTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndListTreeNode.java index 89123a2..0602b4b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndListTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndListTreeNode.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; @@ -31,14 +31,14 @@ public SndListTreeNode(@NotNull final SndList element, final long objectId) { } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new AddSndAction(nodeTree, this)); } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.LIST_16; } @@ -50,7 +50,7 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final } @Override - @FXThread + @FxThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { final SndList definitionList = getElement(); final List definitions = definitionList.getDefinitions(); @@ -58,7 +58,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override - @FXThread + @FxThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final SndList definitionList = getElement(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java index 14436be..8336e37 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java @@ -2,7 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -30,13 +30,13 @@ public SndParameterTreeNode(@NotNull final ShaderNodeVariable element, final lon } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new DeleteSndarameterAction(nodeTree, this)); } - @FXThread + @FxThread @Override public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { if (StringUtils.equals(getName(), newName)) return; @@ -52,7 +52,7 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.VARIABLE_16; } @@ -64,7 +64,7 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin } @Override - @FXThread + @FxThread public boolean canEditName() { return true; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParametersTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParametersTreeNode.java index 6ca0a6d..8b4af72 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParametersTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParametersTreeNode.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -41,14 +41,14 @@ public SndParametersTreeNode(@NotNull final SndParameters element, final long ob } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return getElement() instanceof SndInputParameters ? PluginIcons.ARROW_RIGHT_16 : PluginIcons.ARROW_LEFT_16; } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); @@ -61,7 +61,7 @@ public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final } @Override - @FXThread + @FxThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { final SndParameters element = getElement(); final List parameters = element.getParameters(); @@ -69,7 +69,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override - @FXThread + @FxThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final SndParameters element = getElement(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourceTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourceTreeNode.java index 42f62df..ce9ee79 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourceTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourceTreeNode.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; import com.ss.editor.shader.nodes.ui.control.tree.action.DeleteSndShaderSourceAction; @@ -25,14 +25,14 @@ public SndShaderSourceTreeNode(@NotNull final SndShaderSource element, final lon } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new DeleteSndShaderSourceAction(nodeTree, this)); } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.CODE_16; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourcesTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourcesTreeNode.java index a4d7cf5..a35e455 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourcesTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndShaderSourcesTreeNode.java @@ -1,12 +1,12 @@ package com.ss.editor.shader.nodes.ui.control.tree.node.definition; -import com.ss.editor.annotation.FXThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSources; -import com.ss.editor.shader.nodes.ui.control.tree.action.AddSndShaderSourceAction; import com.ss.editor.shader.nodes.ui.PluginIcons; +import com.ss.editor.shader.nodes.ui.control.tree.action.AddSndShaderSourceAction; import com.ss.editor.ui.control.tree.NodeTree; import com.ss.editor.ui.control.tree.node.TreeNode; import com.ss.rlib.util.array.Array; @@ -37,20 +37,20 @@ public SndShaderSourcesTreeNode(@NotNull final SndShaderSources element, final l } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new AddSndShaderSourceAction(nodeTree, this)); } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { return PluginIcons.CODE_16; } @Override - @FXThread + @FxThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { final SndShaderSources element = getElement(); final Map sourceMap = element.getShadeSourceMap(); @@ -58,7 +58,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override - @FXThread + @FxThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final SndShaderSources element = getElement(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndTreeNode.java index 337345b..af1571d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndTreeNode.java @@ -2,7 +2,7 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.*; @@ -33,7 +33,7 @@ public SndTreeNode(@NotNull final ShaderNodeDefinition element, final long objec } @Override - @FXThread + @FxThread public @Nullable Image getIcon() { final ShaderNodeDefinition element = getElement(); @@ -53,7 +53,7 @@ public SndTreeNode(@NotNull final ShaderNodeDefinition element, final long objec } @Override - @FXThread + @FxThread public void changeName(@NotNull final NodeTree nodeTree, @NotNull final String newName) { if (StringUtils.equals(getName(), newName)) return; @@ -68,19 +68,19 @@ public void changeName(@NotNull final NodeTree nodeTree, @NotNull final Strin } @Override - @FXThread + @FxThread public boolean canEditName() { return true; } @Override - @FXThread + @FxThread public boolean hasChildren(@NotNull final NodeTree nodeTree) { return true; } @Override - @FXThread + @FxThread public @NotNull Array> getChildren(@NotNull final NodeTree nodeTree) { final ShaderNodeDefinition definition = getElement(); @@ -95,7 +95,7 @@ public boolean hasChildren(@NotNull final NodeTree nodeTree) { } @Override - @FXThread + @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); items.add(new DeleteSndAction(nodeTree, this)); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java index 117b385..36e68b2 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; @@ -33,16 +33,16 @@ public AddSndOperation(@NotNull final SndList definitionList, } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().add(definition); - editor.notifyFXAddedChild(definitionList, definition, -1, true); + editor.notifyFxAddedChild(definitionList, definition, -1, true); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().remove(definition); - editor.notifyFXRemovedChild(definitionList, definition); + editor.notifyFxRemovedChild(definitionList, definition); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java index f944b28..3fea416 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndParameterOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -35,18 +35,18 @@ public AddSndParameterOperation(@NotNull final SndParameters parameters, } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.add(variable); - editor.notifyFXAddedChild(parameters, variable, -1, true); + editor.notifyFxAddedChild(parameters, variable, -1, true); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.remove(variable); - editor.notifyFXRemovedChild(parameters, variable); + editor.notifyFxRemovedChild(parameters, variable); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java index 910c824..5d5bb89 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/AddSndShaderSourceOperation.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; @@ -33,16 +33,16 @@ public AddSndShaderSourceOperation(@NotNull final SndShaderSources shaderSources } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { shaderSources.add(shaderSource); - editor.notifyFXAddedChild(shaderSources, shaderSource, -1, true); + editor.notifyFxAddedChild(shaderSources, shaderSource, -1, true); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { shaderSources.remove(shaderSource); - editor.notifyFXRemovedChild(shaderSources, shaderSources); + editor.notifyFxRemovedChild(shaderSources, shaderSources); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java index 8ab0bef..e3abbed 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/ChangeSndDocumentationOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import org.jetbrains.annotations.NotNull; @@ -34,16 +34,16 @@ public ChangeSndDocumentationOperation(@NotNull final ShaderNodeDefinition defin } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definition.setDocumentation(newDocumentation); - editor.notifyFXChangeProperty(definition, "documentation"); + editor.notifyFxChangeProperty(definition, "documentation"); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definition.setDocumentation(oldDocumentation); - editor.notifyFXChangeProperty(definition, "documentation"); + editor.notifyFxChangeProperty(definition, "documentation"); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java index e40ad92..a8d1d9d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; @@ -40,18 +40,18 @@ public DeleteSndOperation(@NotNull final SndList definitionList, } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { final List definitions = definitionList.getDefinitions(); index = definitions.indexOf(definition); definitions.remove(definition); - editor.notifyFXRemovedChild(definitionList, definition); + editor.notifyFxRemovedChild(definitionList, definition); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definitionList.getDefinitions().add(index, definition); - editor.notifyFXAddedChild(definitionList, definition, index, false); + editor.notifyFxAddedChild(definitionList, definition, index, false); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java index beea36d..e6c5b61 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndParameterOperation.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; import com.jme3.shader.ShaderNodeVariable; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -40,19 +40,19 @@ public DeleteSndParameterOperation(@NotNull final SndParameters parameters, } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); index = parameterList.indexOf(variable); parameterList.remove(variable); - editor.notifyFXRemovedChild(parameters, variable); + editor.notifyFxRemovedChild(parameters, variable); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { final List parameterList = parameters.getParameters(); parameterList.add(index, variable); - editor.notifyFXAddedChild(parameters, variable, index, false); + editor.notifyFxAddedChild(parameters, variable, index, false); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java index d45d0c8..c18c0b8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/DeleteSndShaderSourceOperation.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.control.tree.operation; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndShaderSource; @@ -38,17 +38,17 @@ public DeleteSndShaderSourceOperation(@NotNull final SndShaderSources shaderSour } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { index = shaderSources.indexOf(shaderSource); shaderSources.remove(shaderSource); - editor.notifyFXRemovedChild(shaderSources, shaderSource); + editor.notifyFxRemovedChild(shaderSources, shaderSource); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { shaderSources.add(index, shaderSource); - editor.notifyFXAddedChild(shaderSources, shaderSource, index, false); + editor.notifyFxAddedChild(shaderSources, shaderSource, index, false); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java index 7d5d135..4a16a09 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndList; @@ -49,16 +49,16 @@ public RenameSndOperation(@NotNull final String oldName, @NotNull final String n } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { definition.setName(newName); - editor.notifyFXChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); + editor.notifyFxChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { definition.setName(oldName); - editor.notifyFXChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); + editor.notifyFxChangeProperty(definitionList, definition, Messages.MODEL_PROPERTY_NAME); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java index acf6225..1bed5b2 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/operation/RenameSndParameterOperation.java @@ -2,7 +2,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.model.undo.impl.AbstractEditorOperation; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; @@ -49,16 +49,16 @@ public RenameSndParameterOperation(@NotNull final String oldName, @NotNull final } @Override - @FXThread + @FxThread protected void redoImpl(@NotNull final ChangeConsumer editor) { variable.setName(newName); - editor.notifyFXChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); + editor.notifyFxChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); } @Override - @FXThread + @FxThread protected void undoImpl(@NotNull final ChangeConsumer editor) { variable.setName(oldName); - editor.notifyFXChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); + editor.notifyFxChangeProperty(parameters, variable, Messages.MODEL_PROPERTY_NAME); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java index 5ba86ff..5fb2736 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/property/ShaderNodesPropertyBuilder.java @@ -4,14 +4,14 @@ import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.extension.property.EditableProperty; import com.ss.editor.extension.property.SimpleProperty; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.ui.control.property.builder.PropertyBuilder; import com.ss.editor.ui.control.property.builder.impl.EditableObjectPropertyBuilder; -import com.ss.editor.util.GLSLType; +import com.ss.editor.util.GlslType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,9 +27,9 @@ public class ShaderNodesPropertyBuilder extends EditableObjectPropertyBuilder { @NotNull - private static final EnumSet NOT_AVAILABLE_DEFAULT_VALUE = EnumSet.of( - GLSLType.SAMPLER_2D, - GLSLType.SAMPLER_CUBE + private static final EnumSet NOT_AVAILABLE_DEFAULT_VALUE = EnumSet.of( + GlslType.SAMPLER_2D, + GlslType.SAMPLER_CUBE ); /** @@ -53,7 +53,7 @@ protected ShaderNodesPropertyBuilder() { } @Override - @FXThread + @FxThread protected @Nullable List> getProperties(@NotNull final Object object) { if (!(object instanceof ShaderNodeDefinition || object instanceof ShaderNodeVariable)) { @@ -72,10 +72,10 @@ protected ShaderNodesPropertyBuilder() { } else if (object instanceof ShaderNodeVariable) { final ShaderNodeVariable variable = (ShaderNodeVariable) object; - final GLSLType glslType = GLSLType.ofRawType(variable.getType()); + final GlslType glslType = GlslType.ofRawType(variable.getType()); result.add(new SimpleProperty<>(ENUM, Messages.MODEL_PROPERTY_TYPE, variable, - var -> GLSLType.ofRawType(var.getType()), + var -> GlslType.ofRawType(var.getType()), (var, type) -> var.setType(type.getRawType()))); if (!NOT_AVAILABLE_DEFAULT_VALUE.contains(glslType)) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java index 9e40865..4b867ca 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java @@ -1,15 +1,15 @@ package com.ss.editor.shader.nodes.ui.dialog; -import static com.ss.editor.ui.util.UIUtils.consumeIf; +import static com.ss.editor.ui.util.UiUtils.consumeIf; import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.control.tree.operation.ChangeSndDocumentationOperation; -import com.ss.editor.shader.nodes.ui.PluginCSSClasses; +import com.ss.editor.shader.nodes.ui.PluginCssClasses; import com.ss.editor.shader.nodes.ui.component.SndDocumentationArea; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.rlib.ui.util.FXUtils; @@ -61,13 +61,13 @@ public EditSndDocumentationDialog(@NotNull final ChangeConsumer consumer, * * @return the editor area. */ - @FXThread + @FxThread private @NotNull SndDocumentationArea getEditorArea() { return notNull(editorArea); } @Override - @FXThread + @FxThread protected void createContent(@NotNull final VBox root) { super.createContent(root); @@ -75,7 +75,7 @@ protected void createContent(@NotNull final VBox root) { editorArea.setOnKeyReleased(event -> consumeIf(event, keyEvent -> keyEvent.getCode() == KeyCode.ENTER)); - FXUtils.addClassTo(editorArea, PluginCSSClasses.SHADER_NODE_DEF_DOCUMENTATION_DIALOG); + FXUtils.addClassTo(editorArea, PluginCssClasses.SHADER_NODE_DEF_DOCUMENTATION_DIALOG); FXUtils.addToPane(editorArea, root); } @@ -92,7 +92,7 @@ protected void createContent(@NotNull final VBox root) { } @Override - @FXThread + @FxThread protected void processOk() { super.processOk(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java index 9148d14..c1d1d97 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java @@ -3,9 +3,8 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.ShaderNodeDefinitionKey; import com.jme3.shader.ShaderNodeDefinition; -import com.ss.editor.Editor; import com.ss.editor.FileExtensions; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.SndDocumentationArea; import com.ss.editor.ui.preview.impl.AbstractFilePreview; import com.ss.editor.util.EditorUtil; @@ -24,11 +23,8 @@ */ public class SndFilePreview extends AbstractFilePreview { - @NotNull - private static final Editor EDITOR = Editor.getInstance(); - @Override - @FXThread + @FxThread protected @NotNull SndDocumentationArea createGraphicsNode() { final SndDocumentationArea documentationArea = new SndDocumentationArea(); documentationArea.setEditable(false); @@ -36,7 +32,7 @@ public class SndFilePreview extends AbstractFilePreview { } @Override - @FXThread + @FxThread protected void initialize(@NotNull final SndDocumentationArea node, @NotNull final StackPane pane) { super.initialize(node, pane); node.prefWidthProperty().bind(pane.widthProperty()); @@ -44,7 +40,7 @@ protected void initialize(@NotNull final SndDocumentationArea node, @NotNull fin } @Override - @FXThread + @FxThread public void show(@NotNull final Path file) { super.show(file); @@ -52,13 +48,13 @@ public void show(@NotNull final Path file) { final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(assetPath); key.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final List definitionList = assetManager.loadAsset(key); show(definitionList); } - @FXThread + @FxThread private void show(@NotNull final List definitionList) { final SndDocumentationArea documentationArea = getGraphicsNode(); @@ -97,27 +93,27 @@ private void show(@NotNull final List definitionList) { } @Override - @FXThread + @FxThread public void show(@NotNull final String resource) { super.show(resource); final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(resource); key.setLoadDocumentation(true); - final AssetManager assetManager = EDITOR.getAssetManager(); + final AssetManager assetManager = EditorUtil.getAssetManager(); final List definitionList = assetManager.loadAsset(key); show(definitionList); } @Override - @FXThread + @FxThread public boolean isSupport(@NotNull final Path file) { final String extension = FileUtils.getExtension(file); return FileExtensions.JME_SHADER_NODE.equals(extension); } - @FXThread + @FxThread @Override public boolean isSupport(@NotNull final String resource) { final String extension = FileUtils.getExtension(resource); @@ -125,7 +121,7 @@ public boolean isSupport(@NotNull final String resource) { } @Override - @FXThread + @FxThread public int getOrder() { return 10; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java index 7cc784c..05ccdce 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java @@ -1,6 +1,6 @@ package com.ss.editor.shader.nodes.ui.preview; -import com.ss.editor.annotation.FXThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.ui.preview.FilePreview; import com.ss.editor.ui.preview.FilePreviewFactory; import com.ss.rlib.util.array.Array; @@ -21,7 +21,7 @@ public class SndFilePreviewFactory implements FilePreviewFactory { } @Override - @FXThread + @FxThread public void createFilePreviews(@NotNull final Array result) { result.add(new SndFilePreview()); } diff --git a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java index 0ff83c8..74d0030 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java @@ -14,7 +14,7 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.OutputGlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.InputShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; -import com.ss.editor.util.GLSLType; +import com.ss.editor.util.GlslType; import com.ss.rlib.util.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -447,7 +447,7 @@ public static boolean isAccessibleType(@NotNull final String inType, @NotNull fi @FromAnyThread public static boolean isRequired(@NotNull final ShaderNodeVariable variable) { - final GLSLType glslType = GLSLType.ofRawType(variable.getType()); + final GlslType glslType = GlslType.ofRawType(variable.getType()); switch (glslType) { case SAMPLER_2D: From 05a0dea6855a7634dfc903c3ef534b9fd05de5d9 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Mon, 26 Feb 2018 07:18:50 +0300 Subject: [PATCH 11/25] refactoring. --- .../shader/nodes/ShaderNodeElement.java | 20 ++-- .../shader/nodes/ShaderNodesContainer.java | 99 +++++++------------ .../shader/nodes/util/ShaderNodeUtils.java | 52 +++++++++- 3 files changed, 99 insertions(+), 72 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java index f9f6fe4..752d1cd 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java @@ -295,10 +295,10 @@ private void handleMouseDragged(@NotNull final MouseEvent event) { } else { final Parent parent = getParent(); - final Point2D parentCoords = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); + final Point2D posiInParent = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); - double offsetX = parentCoords.getX() - mouseX; - double offsetY = parentCoords.getY() - mouseY; + double offsetX = posiInParent.getX() - mouseX; + double offsetY = posiInParent.getY() - mouseY; x = Math.max(x + offsetX, 10D); y = Math.max(y + offsetY, 10D); @@ -308,8 +308,8 @@ private void handleMouseDragged(@NotNull final MouseEvent event) { setDragging(true); // again set current Mouse x AND y position - mouseX = parentCoords.getX(); - mouseY = parentCoords.getY(); + mouseX = posiInParent.getX(); + mouseY = posiInParent.getY(); } event.consume(); @@ -373,7 +373,9 @@ private void handleMousePressed(@NotNull final MouseEvent event) { if (event.getTarget() instanceof SocketElement) { return; - } else if (event.getButton() != MouseButton.MIDDLE) { + } + + if (event.getButton() != MouseButton.MIDDLE) { container.requestSelect(this); } @@ -383,11 +385,11 @@ private void handleMousePressed(@NotNull final MouseEvent event) { } else { final Parent parent = getParent(); - final Point2D parentCoords = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); + final Point2D posInParent = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); // record the current mouse X and Y position on Node - mouseX = parentCoords.getX(); - mouseY = parentCoords.getY(); + mouseX = posInParent.getX(); + mouseY = posInParent.getY(); x = getLayoutX(); y = getLayoutY(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java index 4dcbb6b..757cc97 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java @@ -16,7 +16,6 @@ import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.add.*; -import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.GlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.InputGlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.OutputGlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.line.TempLine; @@ -25,6 +24,7 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import com.ss.editor.shader.nodes.util.MaterialDefUtils; +import com.ss.editor.shader.nodes.util.ShaderNodeUtils; import com.ss.rlib.logging.Logger; import com.ss.rlib.logging.LoggerManager; import com.ss.rlib.ui.util.FXUtils; @@ -48,10 +48,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.function.Predicate; /** @@ -69,6 +66,7 @@ public class ShaderNodesContainer extends ScrollPane { @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); + /** * All current nodes elements. */ @@ -378,8 +376,7 @@ private void layoutNodes() { */ @FxThread private void resetLayout() { - final Array> nodeElements = getNodeElements(); - nodeElements.forEach(ShaderNodeElement::resetLayout); + getNodeElements().forEach(ShaderNodeElement::resetLayout); } /** @@ -471,6 +468,7 @@ public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { if (source == root) { + //FIXME localization final Menu menu = new Menu("Add"); menu.getItems().addAll(new AddMaterialParamShaderNodeAction(this, materialDef, location), new AddMaterialTextureShaderNodeAction(this, materialDef, location), @@ -513,7 +511,9 @@ public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { public void updateAttaching(final double sceneX, final double sceneY) { final TempLine tempLine = getTempLine(); - if (tempLine == null) return; + if (tempLine == null) { + return; + } final Point2D localCoords = root.sceneToLocal(sceneX, sceneY); tempLine.updateEnd(localCoords.getX(), localCoords.getY()); @@ -526,7 +526,9 @@ public void updateAttaching(final double sceneX, final double sceneY) { public void finishAttaching() { final TempLine tempLine = getTempLine(); - if (tempLine == null) return; + if (tempLine == null) { + return; + } FXUtils.removeFromParent(tempLine, root); setTempLine(null); @@ -566,7 +568,10 @@ public void requestSelect(@NotNull final ShaderNodeElement requester) { */ @FxThread public void show(@NotNull final TechniqueDef techniqueDef) { - if (techniqueDef.equals(this.techniqueDef)) return; + + if (techniqueDef.equals(this.techniqueDef)) { + return; + } this.techniqueDef = techniqueDef; @@ -599,10 +604,7 @@ public void show(@NotNull final TechniqueDef techniqueDef) { nodeElements.add(new OutputGlobalShaderNodeElement(this, shaderGenerationInfo)); for (final ShaderNodeVariable variable : uniforms) { - final ShaderNodeElement nodeElement = createNodeElement(variable); - if (nodeElement != null) { - nodeElements.add(nodeElement); - } + createNodeElement(variable).ifPresent(nodeElements::add); } final List shaderNodes = techniqueDef.getShaderNodes(); @@ -642,13 +644,12 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * Find a shader node by the name. * * @param name the name. - * @return the found shader node or null. + * @return the optional of the shader node. */ @FxThread - public @Nullable ShaderNode findShaderNodeByName(@NotNull final String name) { + private ShaderNode findShaderNodeByName(@NotNull final String name) { - if (MaterialShaderNodeElement.NAMESPACE.equals(name) || GlobalShaderNodeElement.NAMESPACE.equals(name) || - WorldShaderNodeElement.NAMESPACE.equals(name) || AttributeShaderNodeElement.NAMESPACE.equals(name)) { + if (ShaderNodeUtils.isUserShaderNode(name)) { return null; } @@ -713,30 +714,30 @@ public void show(@NotNull final TechniqueDef techniqueDef) { * Find a nodes element by the variable. * * @param variable the variable. - * @return the nodes element or null. + * @return the node element. */ @FxThread - private @Nullable ShaderNodeElement findNodeElementByVariable(@NotNull final ShaderNodeVariable variable) { - return (ShaderNodeElement) root.getChildren().stream() + private @NotNull Optional> findNodeElementByVariable(@NotNull final ShaderNodeVariable variable) { + return root.getChildren().stream() .filter(ShaderNodeElement.class::isInstance) - .map(ShaderNodeElement.class::cast) + .map(sne -> (ShaderNodeElement) sne) .filter(element -> element.getObject().equals(variable)) - .findAny().orElse(null); + .findAny(); } /** * Find a nodes element by the object. * * @param object the object. - * @return the nodes element or null. + * @return the node element. */ @FxThread - private @Nullable ShaderNodeElement findNodeElementByObject(@NotNull final Object object) { - return (ShaderNodeElement) root.getChildren().stream() + private @NotNull Optional> findNodeElementByObject(@NotNull final Object object) { + return root.getChildren().stream() .filter(ShaderNodeElement.class::isInstance) - .map(ShaderNodeElement.class::cast) + .map(sne -> (ShaderNodeElement) sne) .filter(element -> element.getObject().equals(object)) - .findAny().orElse(null); + .findAny(); } /** @@ -749,11 +750,12 @@ public void show(@NotNull final TechniqueDef techniqueDef) { */ @FxThread private @Nullable ShaderNodeParameter findByVariable(@NotNull final ShaderNodeVariable variable, - final boolean fromOutputMapping, final boolean input) { + final boolean fromOutputMapping, + final boolean input) { return root.getChildren().stream() .filter(ShaderNodeElement.class::isInstance) .map(ShaderNodeElement.class::cast) - .map(shaderNodeElement -> shaderNodeElement.parameterFor(variable, fromOutputMapping, input)) + .map(sne -> sne.parameterFor(variable, fromOutputMapping, input)) .filter(Objects::nonNull) .findAny().orElse(null); } @@ -811,13 +813,7 @@ public void addShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final V */ @FxThread public void addNodeElement(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location) { - - final ShaderNodeElement nodeElement = createNodeElement(variable); - if (nodeElement == null) { - return; - } - - addNodeElement(nodeElement, location); + createNodeElement(variable).ifPresent(element -> addNodeElement(element, location)); } /** @@ -872,9 +868,7 @@ public void removeWorldParam(@NotNull final UniformBinding binding) { */ @FxThread public void removeShaderNode(@NotNull final ShaderNode shaderNode) { - final ShaderNodeElement nodeElement = findNodeElementByObject(shaderNode); - if (nodeElement == null) return; - removeNodeElement(nodeElement); + findNodeElementByObject(shaderNode).ifPresent(this::removeNodeElement); } /** @@ -884,13 +878,7 @@ public void removeShaderNode(@NotNull final ShaderNode shaderNode) { */ @FxThread public void removeNodeElement(@NotNull final ShaderNodeVariable variable) { - - final ShaderNodeElement nodeElement = findNodeElementByVariable(variable); - if (nodeElement == null) { - return; - } - - removeNodeElement(nodeElement); + findNodeElementByVariable(variable).ifPresent(this::removeNodeElement); } /** @@ -909,22 +897,11 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) * Create a nodes element for the variable. * * @param variable the variable. - * @return the nodes element. + * @return the optional of shader node element. */ @FxThread - private @Nullable ShaderNodeElement createNodeElement(@NotNull ShaderNodeVariable variable) { - - ShaderNodeElement nodeElement = null; - - final String nameSpace = variable.getNameSpace(); - if (MaterialShaderNodeElement.NAMESPACE.equals(nameSpace)) { - nodeElement = new MaterialShaderNodeElement(this, variable); - } else if (WorldShaderNodeElement.NAMESPACE.equals(nameSpace)) { - nodeElement = new WorldShaderNodeElement(this, variable); - } else if (AttributeShaderNodeElement.NAMESPACE.equals(nameSpace)) { - nodeElement = new AttributeShaderNodeElement(this, variable); - } - return nodeElement; + private @NotNull Optional> createNodeElement(@NotNull final ShaderNodeVariable variable) { + return ShaderNodeUtils.createNodeElement(this, variable); } /** diff --git a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java index 74d0030..153a956 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java @@ -11,16 +11,23 @@ import com.jme3.shader.VariableMapping; import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.GlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.OutputGlobalShaderNodeElement; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.AttributeShaderNodeElement; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MaterialShaderNodeElement; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.WorldShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.InputShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; import com.ss.editor.util.GlslType; import com.ss.rlib.util.StringUtils; +import com.ss.rlib.util.dictionary.DictionaryFactory; +import com.ss.rlib.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.List; +import java.util.*; +import java.util.function.BiFunction; /** * The utility class. @@ -29,6 +36,47 @@ */ public class ShaderNodeUtils { + @NotNull + private static final ObjectDictionary>> NODE_ELEMENT_FACTORIES = + DictionaryFactory.newObjectDictionary(); + + static { + NODE_ELEMENT_FACTORIES.put(MaterialShaderNodeElement.NAMESPACE, MaterialShaderNodeElement::new); + NODE_ELEMENT_FACTORIES.put(WorldShaderNodeElement.NAMESPACE, WorldShaderNodeElement::new); + NODE_ELEMENT_FACTORIES.put(AttributeShaderNodeElement.NAMESPACE, AttributeShaderNodeElement::new); + } + + @NotNull + private static final Set SYSTEM_NAMESPACES = new HashSet<>(Arrays.asList( + MaterialShaderNodeElement.NAMESPACE, + GlobalShaderNodeElement.NAMESPACE, + WorldShaderNodeElement.NAMESPACE, + AttributeShaderNodeElement.NAMESPACE + )); + + /** + * Return true of the node name is user's shader node. + * + * @param shaderNodeName the shader node name. + * @return true of the node name is user's shader node. + */ + public static boolean isUserShaderNode(@NotNull final String shaderNodeName) { + return !SYSTEM_NAMESPACES.contains(shaderNodeName); + } + + /** + * Create a shader node element for the shader node variable. + * + * @param container the shader node container. + * @param var the shader node variable. + * @return the option of shader node element. + */ + public static @NotNull Optional> createNodeElement(@NotNull final ShaderNodesContainer container, + @NotNull final ShaderNodeVariable var) { + return NODE_ELEMENT_FACTORIES.getOptional(var.getNameSpace()) + .map(factory -> factory.apply(container, var)); + } + /** * Find a material parameter with the name. * From f9cf5f6a3e11ac66e707398521dc3daf3d90115f Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Mon, 26 Feb 2018 08:40:40 +0300 Subject: [PATCH 12/25] continue to work on shader node value mapping. --- .../ui/component/shader/nodes/ShaderNodeElement.java | 10 +++++----- .../shader/nodes/parameter/ShaderNodeParameter.java | 8 ++++++++ .../nodes/ui/dialog/EditSndDocumentationDialog.java | 2 ++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java index 752d1cd..b5cbe6d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java @@ -295,10 +295,10 @@ private void handleMouseDragged(@NotNull final MouseEvent event) { } else { final Parent parent = getParent(); - final Point2D posiInParent = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); + final Point2D posInParent = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); - double offsetX = posiInParent.getX() - mouseX; - double offsetY = posiInParent.getY() - mouseY; + double offsetX = posInParent.getX() - mouseX; + double offsetY = posInParent.getY() - mouseY; x = Math.max(x + offsetX, 10D); y = Math.max(y + offsetY, 10D); @@ -308,8 +308,8 @@ private void handleMouseDragged(@NotNull final MouseEvent event) { setDragging(true); // again set current Mouse x AND y position - mouseX = posiInParent.getX(); - mouseY = posiInParent.getY(); + mouseX = posInParent.getX(); + mouseY = posInParent.getY(); } event.consume(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java index de3f0a1..22e196b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java @@ -81,6 +81,8 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, } /** + * Get the type label. + * * @return the type label. */ @FxThread @@ -89,6 +91,8 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, } /** + * Get the name label. + * * @return the name label. */ @FxThread @@ -97,6 +101,8 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, } /** + * Get the socket. + * * @return the socket. */ @FxThread @@ -105,6 +111,8 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, } /** + * Get the variable. + * * @return the variable. */ @FxThread diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java index 4b867ca..956b895 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java @@ -52,6 +52,7 @@ public EditSndDocumentationDialog(@NotNull final ChangeConsumer consumer, @NotNull final ShaderNodeDefinition definition) { this.consumer = consumer; this.definition = definition; + //TODO replace to using util method final String documentation = definition.getDocumentation(); getEditorArea().loadContent(documentation == null ? "" : documentation.trim()); } @@ -97,6 +98,7 @@ protected void processOk() { super.processOk(); final String documentation = definition.getDocumentation(); + //TODO replace to using util method final String oldVersion = documentation == null? "" : documentation; final String newVersion = getEditorArea().getText(); From e73d91e8f8cf3e4247a719f7efcef8b0dd330142 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Thu, 15 Mar 2018 16:23:37 +0300 Subject: [PATCH 13/25] updated build script for java 9 --- build.gradle | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index e5ab979..320e234 100644 --- a/build.gradle +++ b/build.gradle @@ -14,14 +14,15 @@ apply plugin: 'java' apply plugin: 'maven' apply plugin: 'idea' apply plugin: 'org.junit.platform.gradle.plugin' +apply plugin: 'application' group = 'com.spaceshift' version = '1.1.1' ext.artifactId = 'shader-nodes' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 1.9 +targetCompatibility = 1.9 compileTestJava { sourceCompatibility = 1.8 @@ -29,6 +30,8 @@ compileTestJava { options.compilerArgs += '-parameters' } +mainClassName = "com.ss.editor.DevelopPluginStarter" + ext.junitPlatformVersion = "1.0.0" ext.junitJupiterVersion = "5.0.0" ext.log4jVersion = '2.6.2' @@ -47,6 +50,7 @@ repositories { mavenCentral() jcenter() maven { url 'https://jitpack.io' } + maven { url "https://dl.bintray.com/javasabr/maven" } } configurations { @@ -58,7 +62,7 @@ javadoc { } dependencies { - compile 'com.github.JavaSaBr:jmonkeybuilder:develop-SNAPSHOT' + compile 'com.spaceshift:jmonkeybuilder:1.7.3-2' testCompile "org.junit.platform:junit-platform-commons:$junitPlatformVersion" testRuntime "org.junit.platform:junit-platform-engine:$junitPlatformVersion" @@ -73,21 +77,6 @@ dependencies { testCompile "org.junit.platform:junit-platform-launcher:$junitPlatformVersion" } -task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -artifacts { - archives sourcesJar - archives javadocJar -} - task cleanPluginFolders(type: Delete) { doFirst { @@ -182,12 +171,8 @@ task wrapper(type: Wrapper) { gradleVersion = '4.5.1' } -defaultTasks 'install' +run.dependsOn { + preparePlugin +} -// To specify a license in the pom: -install { - repositories.mavenInstaller { - pom.version = version - pom.artifactId = artifactId - } -} \ No newline at end of file +run.jvmArgs(Arrays.asList("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005")) \ No newline at end of file From 80e5d65a47332c54561089aba4c5e5e7562c07ae Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Fri, 16 Mar 2018 08:22:37 +0300 Subject: [PATCH 14/25] working on value editing. --- build.gradle | 21 ++--- .../shader/nodes/ui/PluginCssClasses.java | 1 + .../shader/nodes/ShaderNodeElement.java | 15 +++- .../parameter/InputShaderNodeParameter.java | 79 ++++++++++++++++++- .../parameter/OutputShaderNodeParameter.java | 7 +- .../nodes/parameter/ShaderNodeParameter.java | 6 +- .../com/ss/editor/shader/nodes/style.css | 17 +++- 7 files changed, 119 insertions(+), 27 deletions(-) diff --git a/build.gradle b/build.gradle index e5ab979..439b464 100644 --- a/build.gradle +++ b/build.gradle @@ -20,12 +20,12 @@ version = '1.1.1' ext.artifactId = 'shader-nodes' -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 1.9 +targetCompatibility = 1.9 compileTestJava { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + sourceCompatibility = 1.9 + targetCompatibility = 1.9 options.compilerArgs += '-parameters' } @@ -47,6 +47,7 @@ repositories { mavenCentral() jcenter() maven { url 'https://jitpack.io' } + maven { url "https://dl.bintray.com/javasabr/maven" } } configurations { @@ -58,7 +59,7 @@ javadoc { } dependencies { - compile 'com.github.JavaSaBr:jmonkeybuilder:develop-SNAPSHOT' + compile 'com.spaceshift:jmonkeybuilder:1.7.3-2' testCompile "org.junit.platform:junit-platform-commons:$junitPlatformVersion" testRuntime "org.junit.platform:junit-platform-engine:$junitPlatformVersion" @@ -180,14 +181,4 @@ task deployPlugin(type: Zip, dependsOn: 'preparePlugin') { task wrapper(type: Wrapper) { gradleVersion = '4.5.1' -} - -defaultTasks 'install' - -// To specify a license in the pom: -install { - repositories.mavenInstaller { - pom.version = version - pom.artifactId = artifactId - } } \ No newline at end of file diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java b/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java index fb76d8d..d5d8c20 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java @@ -14,6 +14,7 @@ public interface PluginCssClasses { @NotNull String SHADER_NODE_HEADER = "header"; @NotNull String SHADER_NODE_PARAMETER = "shader-node-parameter"; @NotNull String SHADER_NODE_INPUT_PARAMETER = "shader-node-input-parameter"; + @NotNull String SHADER_NODE_INPUT_PARAMETER_CONTAINER = "shader-node-input-parameter-container"; @NotNull String SHADER_NODE_OUTPUT_PARAMETER = "shader-node-output-parameter"; @NotNull String SHADER_NODE_MATERIAL_OUTPUT_PARAMETER = "shader-node-material-output-parameter"; @NotNull String SHADER_NODE_PARAMETER_SOCKET = "shader-node-parameter-socket"; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java index b5cbe6d..c8f4084 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java @@ -191,6 +191,8 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, } /** + * Get the container of this nodes. + * * @return the container of this nodes. */ @FxThread @@ -199,6 +201,8 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, } /** + * Get the shader object. + * * @return the shader object. */ @FxThread @@ -216,7 +220,8 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, */ @FxThread public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, - final boolean fromOutputMapping, final boolean input) { + final boolean fromOutputMapping, + final boolean input) { return parametersContainer.getChildren().stream() .filter(ShaderNodeParameter.class::isInstance) .filter(node -> input ? node instanceof InputShaderNodeParameter : node instanceof OutputShaderNodeParameter) @@ -410,6 +415,8 @@ protected boolean isInResizableZone(@NotNull final MouseEvent event) { } /** + * Return true if this nodes is dragging now. + * * @return true if this nodes is dragging now. */ @FxThread @@ -418,6 +425,8 @@ protected boolean isDragging() { } /** + * Set true if this nodes is dragging now. + * * @param dragging true if this nodes is dragging now. */ @FxThread @@ -426,6 +435,8 @@ protected void setDragging(final boolean dragging) { } /** + * Return true if this nodes is resizing now. + * * @return true if this nodes is resizing now. */ @FxThread @@ -434,6 +445,8 @@ protected boolean isResizing() { } /** + * Set true if this nodes is resizing now. + * * @param resizing true if this nodes is resizing now. */ @FxThread diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index 13162a7..eacd78b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -3,10 +3,16 @@ import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_INPUT_PARAMETER; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.annotation.FxThread; +import com.ss.editor.shader.nodes.ui.PluginCssClasses; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.InputSocketElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; +import com.ss.editor.ui.css.CssClasses; import com.ss.rlib.ui.util.FXUtils; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; /** @@ -16,12 +22,61 @@ */ public class InputShaderNodeParameter extends ShaderNodeParameter { + + /** + * The check box to use expression. + */ + @NotNull + private CheckBox useExpression; + + /** + * The label to use an expression. + */ + @NotNull + private Label useExpressionLabel; + + /** + * The field with expression. + */ + @NotNull + private TextField expressionField; + public InputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, @NotNull final ShaderNodeVariable variable) { super(nodeElement, variable); FXUtils.addClassTo(this, SHADER_NODE_INPUT_PARAMETER); } + /** + * Get the checkbox of using expression. + * + * @return the checkbox of using expression. + */ + @FxThread + protected @NotNull CheckBox getUseExpression() { + return useExpression; + } + + /** + * Get the use expression label. + * + * @return the use expression label. + */ + @FxThread + protected @NotNull Label getUseExpressionLabel() { + return useExpressionLabel; + } + + /** + * Get the expression field. + * + * @return the expression field. + */ + @FxThread + protected @NotNull TextField getExpressionField() { + return expressionField; + } + @Override @FxThread protected @NotNull SocketElement createSocket() { @@ -32,8 +87,26 @@ public InputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, @FxThread protected void createContent() { super.createContent(); - FXUtils.addToPane(getSocket(), this); - FXUtils.addToPane(getNameLabel(), this); - FXUtils.addToPane(getTypeLabel(), this); + + this.useExpressionLabel = new Label("expr:"); + this.useExpression = new CheckBox(); + this.expressionField = new TextField(); + this.expressionField.prefWidthProperty().bind(widthProperty()); + + final HBox parameterContainer = new HBox(getSocket(), getNameLabel(), getTypeLabel()); + parameterContainer.prefWidthProperty().bind(widthProperty()); + + final HBox expressionContainer = new HBox(expressionField); + expressionContainer.managedProperty().bind(useExpression.selectedProperty()); + expressionContainer.visibleProperty().bind(useExpression.selectedProperty()); + expressionContainer.prefWidthProperty().bind(widthProperty()); + + add(parameterContainer, 0, 0); + add(getUseExpressionLabel(), 1, 0); + add(getUseExpression(), 2, 0); + add(expressionContainer, 0, 1, 3, 1); + + FXUtils.addClassTo(parameterContainer, PluginCssClasses.SHADER_NODE_INPUT_PARAMETER_CONTAINER); + FXUtils.addClassTo(expressionContainer, CssClasses.DEF_HBOX); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java index 81a7ca1..141f01e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java @@ -32,9 +32,8 @@ public OutputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement @FxThread protected void createContent() { super.createContent(); - - FXUtils.addToPane(getTypeLabel(), this); - FXUtils.addToPane(getNameLabel(), this); - FXUtils.addToPane(getSocket(), this); + add(getTypeLabel(), 0, 0); + add(getNameLabel(), 1, 0); + add(getSocket(), 2, 0); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java index 22e196b..c29ed21 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java @@ -8,7 +8,7 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import com.ss.rlib.ui.util.FXUtils; import javafx.scene.control.Label; -import javafx.scene.layout.HBox; +import javafx.scene.layout.GridPane; import org.jetbrains.annotations.NotNull; /** @@ -16,7 +16,7 @@ * * @author JavaSaBr */ -public class ShaderNodeParameter extends HBox { +public class ShaderNodeParameter extends GridPane { /** * The shader nodes element. @@ -112,7 +112,7 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, /** * Get the variable. - * + * * @return the variable. */ @FxThread diff --git a/src/main/resources/com/ss/editor/shader/nodes/style.css b/src/main/resources/com/ss/editor/shader/nodes/style.css index 7e65f37..3f55bed 100644 --- a/src/main/resources/com/ss/editor/shader/nodes/style.css +++ b/src/main/resources/com/ss/editor/shader/nodes/style.css @@ -34,7 +34,7 @@ } .shader-node-parameter { - -fx-spacing: 2px; + -fx-hgap: 2px; } .shader-node-input-parameter { @@ -42,6 +42,21 @@ -fx-padding: 0px 0px 0px -4px; } +.shader-node-input-parameter > .label { + -fx-min-width: 40px; + -fx-alignment: center-right; +} + +.shader-node-input-parameter-container { + -fx-alignment: center-left; +} + + +.shader-node-input-parameter > .hbox { + -fx-padding: 1px 3px 1px 8px; + -fx-alignment: center; +} + .shader-node-output-parameter { -fx-alignment: center-right; -fx-padding: 0px -4px 0px 0px; From 19c7e4c8dda569c62a7eb38a42a1c8c8897e12ff Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Tue, 27 Mar 2018 10:09:40 +0300 Subject: [PATCH 15/25] updated to java10 --- build.gradle | 12 ++++++------ gradle/wrapper/gradle-wrapper.jar | Bin 54333 -> 54329 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index fd22e63..98e3b46 100644 --- a/build.gradle +++ b/build.gradle @@ -21,12 +21,12 @@ version = '1.1.1' ext.artifactId = 'shader-nodes' -sourceCompatibility = 1.9 -targetCompatibility = 1.9 +sourceCompatibility = 1.10 +targetCompatibility = 1.10 compileTestJava { - sourceCompatibility = 1.9 - targetCompatibility = 1.9 + sourceCompatibility = 1.10 + targetCompatibility = 1.10 options.compilerArgs += '-parameters' } @@ -62,7 +62,7 @@ javadoc { } dependencies { - compile 'com.spaceshift:jmonkeybuilder:1.7.3-2' + compile 'com.spaceshift:jmonkeybuilder:1.7.3-3' testCompile "org.junit.platform:junit-platform-commons:$junitPlatformVersion" testRuntime "org.junit.platform:junit-platform-engine:$junitPlatformVersion" @@ -168,7 +168,7 @@ task deployPlugin(type: Zip, dependsOn: 'preparePlugin') { } task wrapper(type: Wrapper) { - gradleVersion = '4.5.1' + gradleVersion = '4.6' } run.dependsOn { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c44b679acd3f794ddbb3aa5e919244914911014a..f6b961fd5a86aa5fbfe90f707c3138408be7c718 100644 GIT binary patch delta 757 zcmY+CUr3Wt7{+&AW7C-VS!CNcr4&o~L{lkNk~%LkW0;eMX_UJtQ_yA@6BN7{7(@fv zcr37JCEXarC;}s-BKOa2&dpgDb!E_vP@r@Z1<~oSzVg7~Jiq6C&dcHDyqe2-IhW%# z=T){xzBg+$8oSS8*KUn$jWCT@em4K>?d}|n&8o}YXqx`Eht~`FMoX|5pBJnCU4kKa zmfgiru#UZkKX{BbH1I|C;%iW$VkTqZw7eqDyDQ&yYg* z^0L-0tK8#zZM)uL{zF5q1h z($xq&6Fp9*qeA+lW}0Xd@@bo%H<6ILB$H$n)`O*d*sKQhE-56pXRStRwF^0BFM$+O z=unTqo*o&49O;6yq78mu+V3OW1t*?xP*#?Ovxd*oyBk@ zTG%DbCb}p%j8DUryqAQJE=kYlon3L4NN$emaBaDc=0~$wiuGlMtm9eK<4Dp>mI*cN zO`fDlw~9ZK9dvL~MdwN@IXo&p^q6pKMZ%7hOc$qA+dsvhm{O?Ir&@uOh5Dye^iOFK zm@ecg2@PqPF5lT!^3G^+BV9|UXSUhvX$vbu>8gW`!M!>}FJ`l4Egpr7P?3@8_H%d^ z%FvgorK<~E)`-!(&&cdLHZ%R~6uQ^0@Xz&Tt={ziFE#v~n>Yude^;dqE&hSu9GWc- delta 705 zcmYL{-%Ha`7{+(rjm?$j*GjXaTd)e{D~3xfrA01^mTOixDlKYW%oMDZpcjQmAYF7} zlSc~EjINT1VkqRYY;&8=`Ey%dMEwKRMHJLc5FJmp&dvEe&-1=7oWmO&)xH_k`u7`q zHjI_nH5$#C{#tj|=k4D+zI8B-p9jW&hx1k|b(&L7Lzb!?I-4(QwjexR_rC*MBModA ztr05=;X$ODeZh5o0X{`kGBbpu`EW6grwIk_D5rCJVVU9A8_+nbz+q4}ijnKbhETMb z9vVf73AM3`wNbH)>;qO}9(D)TnI^JY9IHGZm|eR$6X{y|)@K&nf1U)-PW+ObaS4bPBl>?F&|#=#u!Oi{qn6TsNdFTeQ*PZizkJMIuq~a*@;R zThjWuc#=wb1s=lNq=I`(oHZk`)JB*3WbW_R%JAv zT5x*BL(aiW*f+RVuYi)Ab`4A0o;*M|MckdvyQ`(p@ Date: Tue, 27 Mar 2018 17:38:23 +0300 Subject: [PATCH 16/25] updated shader node element. --- .../shader/nodes/ShaderNodeElement.java | 37 ++-- .../shader/nodes/ShaderNodesContainer.java | 204 +++++++++--------- .../shader/nodes/line/VariableLine.java | 14 +- .../nodes/main/MainShaderNodeElement.java | 40 ++-- .../parameter/InputShaderNodeParameter.java | 5 +- .../parameter/socket/InputSocketElement.java | 23 +- .../parameter/socket/OutputSocketElement.java | 29 +-- .../nodes/parameter/socket/SocketElement.java | 38 +++- .../ui/dialog/EditSndDocumentationDialog.java | 8 +- .../shader/nodes/util/ShaderNodeUtils.java | 11 + 10 files changed, 224 insertions(+), 185 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java index c8f4084..a2fc1ac 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java @@ -13,6 +13,7 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; +import com.ss.editor.shader.nodes.util.ShaderNodeUtils; import com.ss.rlib.ui.util.FXUtils; import com.ss.rlib.util.StringUtils; import javafx.beans.property.BooleanProperty; @@ -149,7 +150,7 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull */ @FxThread private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { - final ShaderNodesContainer container = getContainer(); + final var container = getContainer(); container.handleContextMenuEvent(event); event.consume(); } @@ -169,11 +170,10 @@ public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, return false; } - final ShaderNodeVariable inVar = inputParameter.getVariable(); - final ShaderNodeVariable outVar = outputParameter.getVariable(); - - final String inType = inVar.getType(); - final String outType = outVar.getType(); + var inVar = inputParameter.getVariable(); + var outVar = outputParameter.getVariable(); + var inType = inVar.getType(); + var outType = outVar.getType(); return isAccessibleType(inType, outType) || !StringUtils.isEmpty(calculateRightSwizzling(inVar, outVar)) || !StringUtils.isEmpty(calculateLeftSwizzling(inVar, outVar)); @@ -224,8 +224,8 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, final boolean input) { return parametersContainer.getChildren().stream() .filter(ShaderNodeParameter.class::isInstance) - .filter(node -> input ? node instanceof InputShaderNodeParameter : node instanceof OutputShaderNodeParameter) .map(ShaderNodeParameter.class::cast) + .filter(node -> input == isInput(node)) .filter(parameter -> parameter.getVariable().getName().equals(variable.getName())) .findAny().orElse(null); } @@ -246,8 +246,8 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, @FxThread protected void createContent() { - final StackPane header = new StackPane(); - final Label titleLabel = new Label(getTitleText()); + var header = new StackPane(); + var titleLabel = new Label(getTitleText()); FXUtils.addClassTo(header, SHADER_NODE_HEADER); @@ -263,8 +263,8 @@ protected void createContent() { */ @FxThread public void resetLayout() { - final double layoutX = getLayoutX(); - final double layoutY = getLayoutY(); + var layoutX = getLayoutX(); + var layoutY = getLayoutY(); setLayoutX(-1D); setLayoutY(-1D); setLayoutX(layoutX); @@ -293,17 +293,16 @@ private void handleMouseDragged(@NotNull final MouseEvent event) { } if (isResizing()) { - final double mouseX = event.getX(); + var mouseX = event.getX(); setPrefWidth(getPrefWidth() + (mouseX - x)); resetLayout(); x = mouseX; } else { - final Parent parent = getParent(); - final Point2D posInParent = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); - - double offsetX = posInParent.getX() - mouseX; - double offsetY = posInParent.getY() - mouseY; + var parent = getParent(); + var posInParent = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); + var offsetX = posInParent.getX() - mouseX; + var offsetY = posInParent.getY() - mouseY; x = Math.max(x + offsetX, 10D); y = Math.max(y + offsetY, 10D); @@ -389,8 +388,8 @@ private void handleMousePressed(@NotNull final MouseEvent event) { x = event.getX(); } else { - final Parent parent = getParent(); - final Point2D posInParent = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); + final var parent = getParent(); + final var posInParent = parent.sceneToLocal(event.getSceneX(), event.getSceneY()); // record the current mouse X and Y position on Node mouseX = posInParent.getX(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java index 757cc97..cb9242d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java @@ -66,7 +66,6 @@ public class ShaderNodesContainer extends ScrollPane { @NotNull private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); - /** * All current nodes elements. */ @@ -131,7 +130,7 @@ public ShaderNodesContainer(@NotNull final ShaderNodesChangeConsumer changeConsu FXUtils.addClassTo(root, SHADER_NODES_ROOT); - final VBox centered = new VBox(zoomNode); + var centered = new VBox(zoomNode); centered.setAlignment(Pos.CENTER); setPannable(true); @@ -178,10 +177,10 @@ public void notifyChangedMaterial() { @FxThread private void invalidateSizes() { - final ShaderNodesChangeConsumer consumer = getChangeConsumer(); - final Array> nodeElements = getNodeElements(); + var consumer = getChangeConsumer(); + var nodeElements = getNodeElements(); - for (final ShaderNodeElement nodeElement : nodeElements) { + for (var nodeElement : nodeElements) { nodeElement.resetLayout(); final Object object = nodeElement.getObject(); @@ -216,12 +215,11 @@ private void invalidateSizes() { @FxThread private void invalidateLayout() { - final ShaderNodesChangeConsumer consumer = getChangeConsumer(); - final Array> nodeElements = getNodeElements(); - - int skipped = 0; + var consumer = getChangeConsumer(); + var nodeElements = getNodeElements(); + var skipped = 0; - for (final ShaderNodeElement nodeElement : nodeElements) { + for (var nodeElement : nodeElements) { nodeElement.resetLayout(); final Object object = nodeElement.getObject(); @@ -261,12 +259,12 @@ private void invalidateLayout() { @FxThread private void layoutNodes() { - final Array> nodeElements = getNodeElements(); - final ShaderNodeElement inputElement = nodeElements.stream() + var nodeElements = getNodeElements(); + var inputElement = nodeElements.stream() .filter(InputGlobalShaderNodeElement.class::isInstance) .findAny().orElse(null); - final ShaderNodeElement outputElement = nodeElements.stream() + var outputElement = nodeElements.stream() .filter(OutputGlobalShaderNodeElement.class::isInstance) .findAny().orElse(null); @@ -274,22 +272,22 @@ private void layoutNodes() { isInput = isInput.or(MaterialShaderNodeElement.class::isInstance) .or(WorldShaderNodeElement.class::isInstance); - final List> inputNodes = nodeElements.stream() + var inputNodes = nodeElements.stream() .filter(isInput) .sorted((first, second) -> StringUtils.compare(first.getClass().getName(), second.getClass().getName())) .collect(toList()); - final List> vertexNodes = nodeElements.stream() + var vertexNodes = nodeElements.stream() .filter(VertexShaderNodeElement.class::isInstance) .collect(toList()); - final List> fragmentNodes = nodeElements.stream() + var fragmentNodes = nodeElements.stream() .filter(FragmentShaderNodeElement.class::isInstance) .collect(toList()); - float inputElementStartX = 10F; - float inputElementStartY = 10F; - float inputElementEndY = inputElementStartY; + var inputElementStartX = 10F; + var inputElementStartY = 10F; + var inputElementEndY = inputElementStartY; if (inputElement != null) { inputElement.autosize(); @@ -302,10 +300,10 @@ private void layoutNodes() { inputElementEndY = (float) (inputElementStartY + inputElement.getHeight() + 30F); } - float inputNodeStartY = inputElementEndY; - float maxInputParameterWidth = 0; + var inputNodeStartY = inputElementEndY; + var maxInputParameterWidth = 0F; - for (final ShaderNodeElement inNode : inputNodes) { + for (var inNode : inputNodes) { inNode.autosize(); inNode.setLayoutX(inputElementStartX); @@ -318,12 +316,12 @@ private void layoutNodes() { maxInputParameterWidth = (float) Math.max(maxInputParameterWidth, inNode.getWidth() + 80D); } - float vertexNodeStartX = inputElementStartX + maxInputParameterWidth; - float vertexNodeStartY = inputElementEndY - 10F; - float maxVertexNodeWidth = 0F; - float maxVertexHeight = 0F; + var vertexNodeStartX = inputElementStartX + maxInputParameterWidth; + var vertexNodeStartY = inputElementEndY - 10F; + var maxVertexNodeWidth = 0F; + var maxVertexHeight = 0F; - for (final ShaderNodeElement vertexNode : vertexNodes) { + for (var vertexNode : vertexNodes) { vertexNode.autosize(); vertexNode.setLayoutX(vertexNodeStartX); @@ -337,12 +335,12 @@ private void layoutNodes() { maxVertexHeight = (float) Math.max(maxVertexHeight, vertexNode.getHeight() + 10D); } - float fragmentNodeStartX = inputElementStartX + maxInputParameterWidth + 40F; - float fragmentNodeStartY = inputElementEndY + 70F + maxVertexHeight; - float maxFragmentNodeWidth = 0F; - float maxFragmentHeight = 0F; + var fragmentNodeStartX = inputElementStartX + maxInputParameterWidth + 40F; + var fragmentNodeStartY = inputElementEndY + 70F + maxVertexHeight; + var maxFragmentNodeWidth = 0F; + var maxFragmentHeight = 0F; - for (final ShaderNodeElement fragmentNode : fragmentNodes) { + for (var fragmentNode : fragmentNodes) { fragmentNode.autosize(); fragmentNode.setLayoutX(fragmentNodeStartX); @@ -356,10 +354,10 @@ private void layoutNodes() { maxFragmentHeight = (float) Math.max(maxFragmentHeight, fragmentNode.getHeight() + 10D); } - float outputStartX = Math.max(fragmentNodeStartX, vertexNodeStartX); + var outputStartX = Math.max(fragmentNodeStartX, vertexNodeStartX); outputStartX += 10D; - float outputStartY = vertexNodeStartY + maxVertexHeight; + var outputStartY = vertexNodeStartY + maxVertexHeight; if (outputElement != null) { outputElement.autosize(); @@ -407,8 +405,7 @@ private void setTempLine(@Nullable final TempLine tempLine) { @FxThread public void startAttaching(@NotNull final SocketElement sourceSocket) { - TempLine tempLine = getTempLine(); - + var tempLine = getTempLine(); if (tempLine != null) { FXUtils.removeFromParent(tempLine, root); setTempLine(null); @@ -453,23 +450,23 @@ private void handleMouseClicked(@NotNull final MouseEvent event) { @FxThread public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { - final Object source = event.getSource(); + var source = event.getSource(); if (contextMenu.isShowing()) { contextMenu.hide(); } - final Vector2f location = new Vector2f((float) event.getX(), (float) event.getY()); - final TechniqueDef techniqueDef = getTechniqueDef(); - final MaterialDef materialDef = getChangeConsumer().getMaterialDef(); + var location = new Vector2f((float) event.getX(), (float) event.getY()); + var techniqueDef = getTechniqueDef(); + var materialDef = getChangeConsumer().getMaterialDef(); - final ObservableList items = contextMenu.getItems(); + var items = contextMenu.getItems(); items.clear(); if (source == root) { //FIXME localization - final Menu menu = new Menu("Add"); + var menu = new Menu("Add"); menu.getItems().addAll(new AddMaterialParamShaderNodeAction(this, materialDef, location), new AddMaterialTextureShaderNodeAction(this, materialDef, location), new AddWorldParamShaderNodeAction(this, techniqueDef, location), @@ -480,8 +477,8 @@ public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { } else if (source instanceof ShaderNodeElement) { - final ShaderNodeElement nodeElement = (ShaderNodeElement) source; - final ShaderNodeAction deleteAction = nodeElement.getDeleteAction(); + var nodeElement = (ShaderNodeElement) source; + var deleteAction = nodeElement.getDeleteAction(); if(deleteAction != null) { items.add(deleteAction); @@ -489,9 +486,9 @@ public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { } else if (source instanceof VariableLine) { - final ShaderNodeParameter parameter = ((VariableLine) source).getInParameter(); - final ShaderNodeElement nodeElement = parameter.getNodeElement(); - final ShaderNodeAction detachAction = nodeElement.getDetachAction((VariableLine) source); + var parameter = ((VariableLine) source).getInParameter(); + var nodeElement = parameter.getNodeElement(); + var detachAction = nodeElement.getDetachAction((VariableLine) source); if (detachAction != null) { items.add(detachAction); @@ -510,12 +507,12 @@ public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { @FxThread public void updateAttaching(final double sceneX, final double sceneY) { - final TempLine tempLine = getTempLine(); + var tempLine = getTempLine(); if (tempLine == null) { return; } - final Point2D localCoords = root.sceneToLocal(sceneX, sceneY); + var localCoords = root.sceneToLocal(sceneX, sceneY); tempLine.updateEnd(localCoords.getX(), localCoords.getY()); } @@ -525,7 +522,7 @@ public void updateAttaching(final double sceneX, final double sceneY) { @FxThread public void finishAttaching() { - final TempLine tempLine = getTempLine(); + var tempLine = getTempLine(); if (tempLine == null) { return; } @@ -542,7 +539,7 @@ public void finishAttaching() { @FxThread public void requestSelect(@NotNull final ShaderNodeElement requester) { - final ObservableList children = root.getChildren(); + var children = root.getChildren(); children.stream().filter(node -> node != requester) .filter(ShaderNodeElement.class::isInstance) .map(node -> (ShaderNodeElement) node) @@ -575,26 +572,26 @@ public void show(@NotNull final TechniqueDef techniqueDef) { this.techniqueDef = techniqueDef; - final ShaderGenerationInfo shaderGenerationInfo = techniqueDef.getShaderGenerationInfo(); - final Pane root = getRoot(); + var shaderGenerationInfo = techniqueDef.getShaderGenerationInfo(); + var root = getRoot(); root.getChildren().clear(); - final Array> nodeElements = getNodeElements(); + var nodeElements = getNodeElements(); nodeElements.clear(); - final ShaderNodesChangeConsumer consumer = getChangeConsumer(); - final MaterialDef materialDef = consumer.getMaterialDef(); + var consumer = getChangeConsumer(); + var materialDef = consumer.getMaterialDef(); - final Map matParams = MaterialDefUtils.getMatParams(materialDef); - final List worldBindings = techniqueDef.getWorldBindings(); + var matParams = MaterialDefUtils.getMatParams(materialDef); + var worldBindings = techniqueDef.getWorldBindings(); final List uniforms = new ArrayList<>(); - for (final MatParam matParam : matParams.values()) { + for (var matParam : matParams.values()) { uniforms.add(MaterialShaderNodeElement.toVariable(matParam)); } - for (final UniformBinding worldBinding : worldBindings) { + for (var worldBinding : worldBindings) { uniforms.add(WorldShaderNodeElement.toVariable(worldBinding)); } @@ -603,14 +600,14 @@ public void show(@NotNull final TechniqueDef techniqueDef) { nodeElements.add(new InputGlobalShaderNodeElement(this, shaderGenerationInfo)); nodeElements.add(new OutputGlobalShaderNodeElement(this, shaderGenerationInfo)); - for (final ShaderNodeVariable variable : uniforms) { + for (var variable : uniforms) { createNodeElement(variable).ifPresent(nodeElements::add); } - final List shaderNodes = techniqueDef.getShaderNodes(); + var shaderNodes = techniqueDef.getShaderNodes(); - for (final ShaderNode shaderNode : shaderNodes) { - final ShaderNodeDefinition definition = shaderNode.getDefinition(); + for (var shaderNode : shaderNodes) { + var definition = shaderNode.getDefinition(); if (definition.getType() == Shader.ShaderType.Vertex) { nodeElements.add(new VertexShaderNodeElement(this, shaderNode)); } else if (definition.getType() == Shader.ShaderType.Fragment) { @@ -618,7 +615,9 @@ public void show(@NotNull final TechniqueDef techniqueDef) { } } - nodeElements.forEach(root.getChildren(), (nodeElement, nodes) -> nodes.add(nodeElement)); + nodeElements.forEach(root.getChildren(), + (nodeElement, nodes) -> nodes.add(nodeElement)); + refreshLines(); EXECUTOR_MANAGER.addFxTask(this::invalidateSizes); @@ -676,10 +675,10 @@ private ShaderNode findShaderNodeByName(@NotNull final String name) { private @NotNull List findUsedFrom(@NotNull final List result, @NotNull final ShaderNode shaderNode) { - for (final VariableMapping mapping : shaderNode.getInputMapping()) { + for (var mapping : shaderNode.getInputMapping()) { - final ShaderNodeVariable rightVariable = mapping.getRightVariable(); - final ShaderNode usedNode = findShaderNodeByName(rightVariable.getNameSpace()); + var rightVariable = mapping.getRightVariable(); + var usedNode = findShaderNodeByName(rightVariable.getNameSpace()); if (usedNode == null || result.contains(usedNode)) { continue; @@ -791,7 +790,8 @@ public void addWorldParam(@NotNull final UniformBinding binding, @NotNull final @FxThread public void addShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location) { - final ShaderNodeDefinition definition = shaderNode.getDefinition(); + var definition = shaderNode.getDefinition(); + final MainShaderNodeElement nodeElement; if (definition.getType() == Shader.ShaderType.Vertex) { @@ -825,10 +825,10 @@ public void addNodeElement(@NotNull final ShaderNodeVariable variable, @NotNull @FxThread private void addNodeElement(@NotNull final ShaderNodeElement nodeElement, @NotNull final Vector2f location) { - final ObservableList children = root.getChildren(); + var children = root.getChildren(); children.add(nodeElement); - final Array> nodeElements = getNodeElements(); + var nodeElements = getNodeElements(); nodeElements.add(nodeElement); refreshLines(); @@ -930,25 +930,25 @@ private void removeNodeElement(@NotNull final ShaderNodeElement nodeElement) @FxThread public void refreshLines() { - final ObservableList children = root.getChildren(); - final List lines = children.stream() + var children = root.getChildren(); + var lines = children.stream() .filter(VariableLine.class::isInstance) .collect(toList()); children.removeAll(lines); - final List shaderNodes = getTechniqueDef().getShaderNodes(); + var shaderNodes = getTechniqueDef().getShaderNodes(); - for (final ShaderNode shaderNode : shaderNodes) { + for (var shaderNode : shaderNodes) { - final List inputMapping = shaderNode.getInputMapping(); - final List outputMapping = shaderNode.getOutputMapping(); + var inputMapping = shaderNode.getInputMapping(); + var outputMapping = shaderNode.getOutputMapping(); buildLines(children, inputMapping, false); buildLines(children, outputMapping, true); } - final List toBack = children.stream() + var toBack = children.stream() .filter(VariableLine.class::isInstance) .collect(toList()); @@ -966,17 +966,17 @@ public void refreshLines() { private void buildLines(@NotNull final ObservableList children, @NotNull final List mappings, final boolean fromOutputMapping) { - for (final VariableMapping variableMapping : mappings) { + for (var variableMapping : mappings) { - final ShaderNodeVariable leftVariable = variableMapping.getLeftVariable(); - final ShaderNodeVariable rightVariable = variableMapping.getRightVariable(); + var leftVariable = variableMapping.getLeftVariable(); + var rightVariable = variableMapping.getRightVariable(); if (rightVariable == null) { continue; } - final ShaderNodeParameter leftParameter = findByVariable(leftVariable, fromOutputMapping, true); - final ShaderNodeParameter rightParameter = findByVariable(rightVariable, fromOutputMapping, false); + var leftParameter = findByVariable(leftVariable, fromOutputMapping, true); + var rightParameter = findByVariable(rightVariable, fromOutputMapping, false); if (leftParameter == null || rightParameter == null) { LOGGER.warning("not found parameters for " + leftVariable + " and " + rightVariable); @@ -1004,30 +1004,30 @@ private void updateScale() { @FxThread private void handleScrollEvent(@NotNull final ScrollEvent event) { - final double zoomFactor = event.getDeltaY() * ZOOM_INTENSITY; - final double newScale = scaleValue + zoomFactor; + var zoomFactor = event.getDeltaY() * ZOOM_INTENSITY; + var newScale = scaleValue + zoomFactor; - final Region content = (Region) getContent(); - final Point2D positionInRoot = root.sceneToLocal(event.getSceneX(), event.getSceneY()); - final Point2D positionInContent = content.sceneToLocal(root.localToScene(positionInRoot)); + var content = (Region) getContent(); + var positionInRoot = root.sceneToLocal(event.getSceneX(), event.getSceneY()); + var positionInContent = content.sceneToLocal(root.localToScene(positionInRoot)); scaleValue = Math.min(Math.max(newScale, 0.2F), 1F); updateScale(); requestLayout(); layout(); - final Point2D newPositionInContent = content.sceneToLocal(root.localToScene(positionInRoot)); - final Point2D diff = newPositionInContent.subtract(positionInContent); + var newPositionInContent = content.sceneToLocal(root.localToScene(positionInRoot)); + var diff = newPositionInContent.subtract(positionInContent); - final Bounds viewport = getViewportBounds(); - final Bounds contentBounds = content.getLayoutBounds(); + var viewport = getViewportBounds(); + var contentBounds = content.getLayoutBounds(); - final double viewScaleX = viewport.getWidth() / contentBounds.getWidth(); - final double viewScaleY = viewport.getHeight() / contentBounds.getHeight(); - final double viewX = diff.getX() * viewScaleX; - final double viewY = diff.getY() * viewScaleY; - final double newHValue = viewX / viewport.getWidth(); - final double newYValue = viewY / viewport.getHeight(); + var viewScaleX = viewport.getWidth() / contentBounds.getWidth(); + var viewScaleY = viewport.getHeight() / contentBounds.getHeight(); + var viewX = diff.getX() * viewScaleX; + var viewY = diff.getY() * viewScaleY; + var newHValue = viewX / viewport.getWidth(); + var newYValue = viewY / viewport.getHeight(); setHvalue(getHvalue() + newHValue); setVvalue(getVvalue() + newYValue); @@ -1052,11 +1052,11 @@ public void notifyMoved(@NotNull final ShaderNodeElement nodeElement) { @FxThread public void notifyResized(@NotNull final ShaderNodeElement nodeElement) { - final Object object = nodeElement.getObject(); - final ShaderNodesChangeConsumer consumer = getChangeConsumer(); - final double width = nodeElement.getPrefWidth(); + var object = nodeElement.getObject(); + var consumer = getChangeConsumer(); + var width = nodeElement.getPrefWidth(); - final Vector2f location = new Vector2f((float) nodeElement.getLayoutX(), (float) nodeElement.getLayoutY()); + var location = new Vector2f((float) nodeElement.getLayoutX(), (float) nodeElement.getLayoutY()); if (object instanceof ShaderNode) { consumer.notifyChangeState((ShaderNode) object, location, width); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java index 75dd89e..fb44566 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/line/VariableLine.java @@ -18,9 +18,15 @@ */ public class VariableLine extends CubicCurve { + /** + * The output parameter. + */ @NotNull private final ShaderNodeParameter outParameter; + /** + * The imput parameter. + */ @NotNull private final ShaderNodeParameter inParameter; @@ -40,8 +46,8 @@ public VariableLine(@NotNull final ShaderNodeParameter outParameter, */ @FxThread private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { - final ShaderNodeElement nodeElement = inParameter.getNodeElement(); - final ShaderNodesContainer container = nodeElement.getContainer(); + var nodeElement = inParameter.getNodeElement(); + var container = nodeElement.getContainer(); container.handleContextMenuEvent(event); event.consume(); } @@ -72,8 +78,8 @@ private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { @FxThread private void configureLine() { - final SocketElement outSocket = outParameter.getSocket(); - final SocketElement inSocket = inParameter.getSocket(); + var outSocket = outParameter.getSocket(); + var inSocket = inParameter.getSocket(); startXProperty().bind(outSocket.centerXPropertyProperty()); startYProperty().bind(outSocket.centerYPropertyProperty()); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java index a5fe69c..deeba9c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java @@ -57,7 +57,7 @@ public MainShaderNodeElement(@NotNull final ShaderNodesContainer container, @Not public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, final boolean fromOutputMapping, final boolean input) { - final ShaderNode shaderNode = getObject(); + var shaderNode = getObject(); if (!shaderNode.getName().equals(variable.getNameSpace())) { return null; } @@ -70,16 +70,16 @@ public MainShaderNodeElement(@NotNull final ShaderNodesContainer container, @Not protected void fillParameters(@NotNull final VBox container) { super.fillParameters(container); - final ShaderNode shaderNode = getObject(); - final ShaderNodeDefinition definition = shaderNode.getDefinition(); - final List inputs = definition.getInputs(); - final List outputs = definition.getOutputs(); + var shaderNode = getObject(); + var definition = shaderNode.getDefinition(); + var inputs = definition.getInputs(); + var outputs = definition.getOutputs(); - for (final ShaderNodeVariable variable : inputs) { + for (var variable : inputs) { FXUtils.addToPane(new InputShaderNodeParameter(this, variable), container); } - for (final ShaderNodeVariable variable : outputs) { + for (var variable : outputs) { FXUtils.addToPane(new OutputShaderNodeParameter(this, variable), container); } } @@ -88,16 +88,16 @@ protected void fillParameters(@NotNull final VBox container) { @FxThread public void attach(@NotNull final InputShaderNodeParameter inputParameter, @NotNull final OutputShaderNodeParameter outputParameter) { - super.attach(inputParameter, outputParameter); - final ShaderNodeElement nodeElement = outputParameter.getNodeElement(); + super.attach(inputParameter, outputParameter); - final ShaderNodeVariable inVar = inputParameter.getVariable(); - final ShaderNodeVariable outVar = outputParameter.getVariable(); - final ShaderNode shaderNode = getObject(); + var nodeElement = outputParameter.getNodeElement(); + var inVar = inputParameter.getVariable(); + var outVar = outputParameter.getVariable(); + var shaderNode = getObject(); + var currentMapping = findInMappingByNLeftVar(shaderNode, inVar); - final VariableMapping currentMapping = findInMappingByNLeftVar(shaderNode, inVar); - final VariableMapping newMapping = makeMapping(inputParameter, outputParameter); + var newMapping = makeMapping(inputParameter, outputParameter); newMapping.setRightSwizzling(calculateRightSwizzling(inVar, outVar)); if (StringUtils.isEmpty(newMapping.getRightSwizzling())) { @@ -108,7 +108,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, return; } - final ShaderNodesChangeConsumer changeConsumer = getContainer().getChangeConsumer(); + final var changeConsumer = getContainer().getChangeConsumer(); if (nodeElement instanceof InputGlobalShaderNodeElement) { changeConsumer.execute(new AttachGlobalToShaderNodeOperation(shaderNode, newMapping, currentMapping)); @@ -117,23 +117,23 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, return; } - final ShaderNodesContainer container = nodeElement.getContainer(); - final TechniqueDef techniqueDef = container.getTechniqueDef(); + var container = nodeElement.getContainer(); + var techniqueDef = container.getTechniqueDef(); if (nodeElement instanceof MainShaderNodeElement) { - final ShaderNode outShaderNode = ((MainShaderNodeElement) nodeElement).getObject(); + var outShaderNode = ((MainShaderNodeElement) nodeElement).getObject(); changeConsumer.execute(new AttachVarToShaderNodeOperation(shaderNode, newMapping, currentMapping, techniqueDef, outShaderNode)); } else if (nodeElement instanceof MaterialShaderNodeElement || nodeElement instanceof WorldShaderNodeElement) { - final Shader.ShaderType type = shaderNode.getDefinition().getType(); + var type = shaderNode.getDefinition().getType(); if (type == Shader.ShaderType.Vertex) { - final List fragmentNodes = container.findWithRightInputVar(newMapping.getLeftVariable(), + final var fragmentNodes = container.findWithRightInputVar(newMapping.getLeftVariable(), FragmentShaderNodeElement.class); newMapping.getLeftVariable().setShaderOutput(!fragmentNodes.isEmpty()); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index eacd78b..c8cb099 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -3,6 +3,7 @@ import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_INPUT_PARAMETER; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.annotation.FxThread; +import com.ss.editor.manager.ExecutorManager; import com.ss.editor.shader.nodes.ui.PluginCssClasses; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.InputSocketElement; @@ -93,10 +94,10 @@ protected void createContent() { this.expressionField = new TextField(); this.expressionField.prefWidthProperty().bind(widthProperty()); - final HBox parameterContainer = new HBox(getSocket(), getNameLabel(), getTypeLabel()); + var parameterContainer = new HBox(getSocket(), getNameLabel(), getTypeLabel()); parameterContainer.prefWidthProperty().bind(widthProperty()); - final HBox expressionContainer = new HBox(expressionField); + var expressionContainer = new HBox(expressionField); expressionContainer.managedProperty().bind(useExpression.selectedProperty()); expressionContainer.visibleProperty().bind(useExpression.selectedProperty()); expressionContainer.prefWidthProperty().bind(widthProperty()); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java index 399fa16..68bd7cf 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java @@ -102,16 +102,16 @@ private void handleDragExited(@NotNull final DragEvent dragEvent) { private void handleDragDropped(@NotNull final DragEvent dragEvent) { droppable.setValue(false); - final InputShaderNodeParameter parameter = (InputShaderNodeParameter) getParameter(); - final ShaderNodeElement nodeElement = parameter.getNodeElement(); + var parameter = (InputShaderNodeParameter) getParameter(); + var nodeElement = parameter.getNodeElement(); - final Object gestureSource = dragEvent.getGestureSource(); + var gestureSource = dragEvent.getGestureSource(); if (!(gestureSource instanceof SocketElement)) { return; } - final SocketElement outputSocket = (SocketElement) gestureSource; - final OutputShaderNodeParameter outputParameter = (OutputShaderNodeParameter) outputSocket.getParameter(); + var outputSocket = (SocketElement) gestureSource; + var outputParameter = (OutputShaderNodeParameter) outputSocket.getParameter(); if (!nodeElement.canAttach(parameter, outputParameter)) { return; @@ -128,22 +128,23 @@ private void handleDragDropped(@NotNull final DragEvent dragEvent) { @FxThread private void handleDragOver(@NotNull final DragEvent dragEvent) { - final InputShaderNodeParameter parameter = (InputShaderNodeParameter) getParameter(); - final ShaderNodeElement nodeElement = parameter.getNodeElement(); - final ShaderNodesContainer container = nodeElement.getContainer(); + var parameter = (InputShaderNodeParameter) getParameter(); + var nodeElement = parameter.getNodeElement(); + var container = nodeElement.getContainer(); container.updateAttaching(dragEvent.getSceneX(), dragEvent.getSceneY()); - final Object gestureSource = dragEvent.getGestureSource(); + var gestureSource = dragEvent.getGestureSource(); if (!(gestureSource instanceof SocketElement)) { return; } - final SocketElement outputSocket = (SocketElement) gestureSource; + var outputSocket = (SocketElement) gestureSource; if (!nodeElement.canAttach(parameter, (OutputShaderNodeParameter) outputSocket.getParameter())) { return; } - final Point2D scene = localToScene(getWidth() / 2, getHeight() / 2); + var scene = localToScene(getWidth() / 2, getHeight() / 2); + container.updateAttaching(scene.getX(), scene.getY()); dragEvent.acceptTransferModes(TransferMode.MOVE); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java index f5243d5..632a6f2 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java @@ -62,12 +62,15 @@ public OutputSocketElement(@NotNull final ShaderNodeParameter parameter) { * @param mouseEvent the mouse event. */ @FxThread - private void handleMouseDragged(final MouseEvent mouseEvent) { - final ShaderNodeParameter parameter = getParameter(); - final ShaderNodeElement nodeElement = parameter.getNodeElement(); - final ShaderNodesContainer container = nodeElement.getContainer(); + private void handleMouseDragged(@NotNull final MouseEvent mouseEvent) { + + var container = getParameter() + .getNodeElement() + .getContainer(); + container.startAttaching(this); container.updateAttaching(mouseEvent.getSceneX(), mouseEvent.getSceneY()); + mouseEvent.consume(); } @@ -80,12 +83,12 @@ private void handleMouseDragged(final MouseEvent mouseEvent) { private void handleStopDrag(@NotNull final DragEvent dragEvent) { setCursor(Cursor.DEFAULT); - final ShaderNodeParameter parameter = getParameter(); - final ShaderNodeElement nodeElement = parameter.getNodeElement(); - final ShaderNodesContainer container = nodeElement.getContainer(); - container.finishAttaching(); + getParameter().getNodeElement() + .getContainer() + .finishAttaching(); dragEvent.consume(); + dragged.setValue(false); } @@ -98,15 +101,15 @@ private void handleStopDrag(@NotNull final DragEvent dragEvent) { private void handleStartDrag(@NotNull final MouseEvent mouseEvent) { setCursor(Cursor.MOVE); - final ClipboardContent content = new ClipboardContent(); + var content = new ClipboardContent(); content.put(DATA_FORMAT, ""); - final Dragboard dragBoard = startDragAndDrop(TransferMode.MOVE); + var dragBoard = startDragAndDrop(TransferMode.MOVE); dragBoard.setContent(content); - final ShaderNodeParameter parameter = getParameter(); - final ShaderNodeElement nodeElement = parameter.getNodeElement(); - final ShaderNodesContainer container = nodeElement.getContainer(); + var parameter = getParameter(); + var nodeElement = parameter.getNodeElement(); + var container = nodeElement.getContainer(); container.startAttaching(this); container.updateAttaching(mouseEvent.getSceneX(), mouseEvent.getSceneY()); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java index 55e0aac..683ac60 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java @@ -1,6 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket; import com.ss.editor.annotation.FxThread; +import com.ss.editor.manager.ExecutorManager; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; import javafx.beans.property.DoubleProperty; @@ -20,6 +21,9 @@ */ public class SocketElement extends Pane { + @NotNull + private static final ExecutorManager EXECUTOR_MANAGER = ExecutorManager.getInstance(); + /** * The center X property. */ @@ -43,9 +47,11 @@ public SocketElement(@NotNull final ShaderNodeParameter parameter) { this.centerXProperty = new SimpleDoubleProperty(); this.centerYProperty = new SimpleDoubleProperty(); - final ShaderNodeElement nodeElement = parameter.getNodeElement(); - nodeElement.layoutXProperty().addListener(this::updateCenterCoords); - nodeElement.layoutYProperty().addListener(this::updateCenterCoords); + var element = parameter.getNodeElement(); + element.layoutXProperty().addListener(this::updateCenterCoords); + element.layoutYProperty().addListener(this::updateCenterCoords); + element.heightProperty().addListener((observable, oldValue, newValue) -> + EXECUTOR_MANAGER.addFxTask(this::updateCenterCoords)); } /** @@ -58,6 +64,14 @@ public SocketElement(@NotNull final ShaderNodeParameter parameter) { return parameter; } + /** + * Update coords of this socket. + */ + @FxThread + public void updateCenterCoords() { + updateCenterCoords(null, null, null); + } + /** * Update coords of this socket. * @@ -67,24 +81,26 @@ public SocketElement(@NotNull final ShaderNodeParameter parameter) { */ @FxThread private void updateCenterCoords(@Nullable final ObservableValue observable, - @Nullable final Number oldValue, @Nullable final Number newValue) { - - final ShaderNodeParameter parameter = getParameter(); - final ShaderNodeElement nodeElement = parameter.getNodeElement(); - final Parent parent = nodeElement.getParent(); + @Nullable final Number oldValue, + @Nullable final Number newValue) { + var parameter = getParameter(); + var nodeElement = parameter.getNodeElement(); + var parent = nodeElement.getParent(); if (parent == null) { return; } - final Point2D scene = localToScene(getWidth() / 2, getHeight() / 2); - final Point2D local = parent.sceneToLocal(scene.getX(), scene.getY()); + var scene = localToScene(getWidth() / 2, getHeight() / 2); + var local = parent.sceneToLocal(scene.getX(), scene.getY()); centerXProperty.setValue(local.getX()); centerYProperty.setValue(local.getY()); } /** + * Get the center X property. + * * @return the center X property. */ @FxThread @@ -93,6 +109,8 @@ private void updateCenterCoords(@Nullable final ObservableValue Date: Wed, 28 Mar 2018 17:17:22 +0300 Subject: [PATCH 17/25] continue working on value mapping. --- .../editor/shader/nodes/PluginMessages.java | 1 + .../editor/ShaderNodesFileEditor.java | 16 ++++- .../shader/nodes/ShaderNodeElement.java | 15 +++- .../shader/nodes/ShaderNodesContainer.java | 60 +++++++++++----- .../shader/nodes/action/ShaderNodeAction.java | 17 +++-- .../add/AddAttributeShaderNodeAction.java | 2 +- .../RemoveAttributeShaderNodeAction.java | 13 ++-- .../RemoveMaterialParamShaderNodeAction.java | 16 ++--- .../RemoveRelationShaderNodeAction.java | 27 ++++---- .../action/remove/RemoveShaderNodeAction.java | 29 ++++---- .../RemoveWorldParamShaderNodeAction.java | 17 +++-- .../nodes/main/MainShaderNodeElement.java | 24 ++++--- .../attach/AttachShaderNodeOperation.java | 3 +- .../parameter/InputShaderNodeParameter.java | 69 ++++++++++++++++++- .../nodes/parameter/ShaderNodeParameter.java | 18 ++--- .../shader/nodes/util/ShaderNodeUtils.java | 62 +++++++++++++---- .../shader/nodes/messages/messages.properties | 1 + .../nodes/messages/messages_ru.properties | 1 + .../com/ss/editor/shader/nodes/style.css | 3 +- 19 files changed, 275 insertions(+), 119 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/PluginMessages.java b/src/main/java/com/ss/editor/shader/nodes/PluginMessages.java index 949bd05..ab52649 100644 --- a/src/main/java/com/ss/editor/shader/nodes/PluginMessages.java +++ b/src/main/java/com/ss/editor/shader/nodes/PluginMessages.java @@ -58,6 +58,7 @@ public interface PluginMessages { @NotNull String NODE_ELEMENT_VERTEX_ATTRIBUTE = RESOURCE_BUNDLE.getString("NodeElementVertexAttribute"); @NotNull String NODE_ELEMENT_WORLD_PARAMETER = RESOURCE_BUNDLE.getString("NodeElementWorldParameter"); @NotNull String NODE_ELEMENT_MATERIAL_PARAMETER = RESOURCE_BUNDLE.getString("NodeElementMaterialParameter"); + @NotNull String NODE_ELEMENT_USE_EXPRESSION = RESOURCE_BUNDLE.getString("NodeElementUseExpression"); @NotNull String TREE_NODE_PREVIEW_MATERIAL_SETTINGS = RESOURCE_BUNDLE.getString("TreeNodePreviewMaterialSettings"); @NotNull String TREE_NODE_SHADER_NODE_DEFINITIONS = RESOURCE_BUNDLE.getString("TreeNodeShaderNodeDefinitions"); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index 59e0e2a..5f18110 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -837,15 +837,25 @@ private void buildMaterial() { @FxThread public void notifyAddedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.refreshLines(); + handleChangeMapping(shaderNode); } @Override @FxThread public void notifyRemovedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); + handleChangeMapping(shaderNode); + } + + /** + * Handle of changing mapping of the shader node. + * + * @param shaderNode the shader node. + */ + @FxThread + protected void handleChangeMapping(@NotNull final ShaderNode shaderNode) { + var container = getShaderNodesContainer(); + container.refreshShaderNode(shaderNode); container.refreshLines(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java index a2fc1ac..03a2bd3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodeElement.java @@ -150,9 +150,7 @@ public ShaderNodeElement(@NotNull final ShaderNodesContainer container, @NotNull */ @FxThread private void handleContextMenuRequested(@NotNull final ContextMenuEvent event) { - final var container = getContainer(); - container.handleContextMenuEvent(event); - event.consume(); + getContainer().handleContextMenuEvent(event); } /** @@ -271,6 +269,17 @@ public void resetLayout() { setLayoutY(layoutY); } + /** + * Refresh this component. + */ + @FxThread + public void refresh() { + getParametersContainer().getChildren() + .stream() + .map(ShaderNodeParameter.class::cast) + .forEach(ShaderNodeParameter::refresh); + } + /** * Fill parameters of this nodes. * diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java index cb9242d..09de574 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/ShaderNodesContainer.java @@ -7,20 +7,19 @@ import static java.util.stream.Collectors.toList; import com.jme3.material.MatParam; import com.jme3.material.MaterialDef; -import com.jme3.material.ShaderGenerationInfo; import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.*; import com.ss.editor.annotation.FxThread; import com.ss.editor.manager.ExecutorManager; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; -import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.add.*; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.InputGlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.OutputGlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.line.TempLine; import com.ss.editor.shader.nodes.ui.component.shader.nodes.line.VariableLine; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.*; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.InputShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import com.ss.editor.shader.nodes.util.MaterialDefUtils; @@ -32,14 +31,11 @@ import com.ss.rlib.util.array.Array; import com.ss.rlib.util.array.ArrayFactory; import javafx.collections.ObservableList; -import javafx.geometry.Bounds; -import javafx.geometry.Point2D; import javafx.geometry.Pos; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.control.ContextMenu; import javafx.scene.control.Menu; -import javafx.scene.control.MenuItem; import javafx.scene.control.ScrollPane; import javafx.scene.input.*; import javafx.scene.layout.Pane; @@ -50,6 +46,7 @@ import java.util.*; import java.util.function.Predicate; +import java.util.stream.Collectors; /** * The container of all shader nodes. @@ -496,6 +493,8 @@ public void handleContextMenuEvent(@NotNull final ContextMenuEvent event) { } contextMenu.show(root, event.getScreenX(), event.getScreenY()); + + event.consume(); } /** @@ -539,11 +538,11 @@ public void finishAttaching() { @FxThread public void requestSelect(@NotNull final ShaderNodeElement requester) { - var children = root.getChildren(); - children.stream().filter(node -> node != requester) - .filter(ShaderNodeElement.class::isInstance) - .map(node -> (ShaderNodeElement) node) - .forEach(element -> element.setSelected(false)); + root.getChildren().stream() + .filter(node -> node != requester) + .filter(ShaderNodeElement.class::isInstance) + .map(node -> (ShaderNodeElement) node) + .forEach(element -> element.setSelected(false)); requester.setSelected(true); } @@ -660,6 +659,20 @@ private ShaderNode findShaderNodeByName(@NotNull final String name) { .findAny().orElse(null); } + /** + * Find a variable line for the shader node input parameter. + * + * @param parameter the input parameter. + * @return a variable line for the shader node input parameter. + */ + public @NotNull Optional findLineByInParameter(@NotNull final InputShaderNodeParameter parameter) { + return root.getChildren().stream() + .filter(VariableLine.class::isInstance) + .map(VariableLine.class::cast) + .filter(line -> line.getInParameter() == parameter) + .findAny(); + } + /** * Find all shader nodes which are used from the shader node. * @@ -862,13 +875,25 @@ public void removeWorldParam(@NotNull final UniformBinding binding) { } /** - * Remove the shader nodes. + * Remove the shader node. * - * @param shaderNode the shader nodes. + * @param shaderNode the shader node. */ @FxThread public void removeShaderNode(@NotNull final ShaderNode shaderNode) { - findNodeElementByObject(shaderNode).ifPresent(this::removeNodeElement); + findNodeElementByObject(shaderNode) + .ifPresent(this::removeNodeElement); + } + + /** + * Refresh the shader node. + * + * @param shaderNode the shader node. + */ + @FxThread + public void refreshShaderNode(@NotNull final ShaderNode shaderNode) { + findNodeElementByObject(shaderNode) + .ifPresent(ShaderNodeElement::refresh); } /** @@ -948,9 +973,11 @@ public void refreshLines() { buildLines(children, outputMapping, true); } + // we need to copy lines to a separated list, + // because the method Node.toBack modifies the children's list. var toBack = children.stream() - .filter(VariableLine.class::isInstance) - .collect(toList()); + .filter(VariableLine.class::isInstance) + .collect(toList()); toBack.forEach(Node::toBack); } @@ -963,7 +990,8 @@ public void refreshLines() { * @param fromOutputMapping true if it's from output mapping. */ @FxThread - private void buildLines(@NotNull final ObservableList children, @NotNull final List mappings, + private void buildLines(@NotNull final ObservableList children, + @NotNull final List mappings, final boolean fromOutputMapping) { for (var variableMapping : mappings) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java index 9c83383..bb3558c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/ShaderNodeAction.java @@ -34,8 +34,10 @@ public abstract class ShaderNodeAction extends MenuItem { @NotNull private final Vector2f location; - public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull final T object, + public ShaderNodeAction(@NotNull final ShaderNodesContainer container, + @NotNull final T object, @NotNull final Vector2f location) { + this.container = container; this.object = object; this.location = location; @@ -43,14 +45,15 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull setOnAction(event -> process()); setText(getName()); - final Image icon = getIcon(); - + var icon = getIcon(); if (icon != null) { setGraphic(new ImageView(icon)); } } /** + * Get the location. + * * @return the location. */ @FxThread @@ -59,6 +62,8 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull } /** + * Get the shader nodes container. + * * @return the shader nodes container. */ @FxThread @@ -67,6 +72,8 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull } /** + * Get the additional object. + * * @return the additional object. */ @FxThread @@ -75,7 +82,7 @@ public ShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull } /** - * Gets name. + * Get the name of this action. * * @return the name of this action. */ @@ -92,7 +99,7 @@ protected void process() { /** * The icon of this action. * - * @return he icon or null. + * @return the icon or null. */ @FxThread protected @Nullable Image getIcon() { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java index 888a54c..1c57bce 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/add/AddAttributeShaderNodeAction.java @@ -72,7 +72,7 @@ protected void addParameter(@NotNull final VarTable vars) { final TechniqueDef techniqueDef = getObject(); final String name = vars.getString(PROP_NAME); - final String attributeUIType = getAttributeUIType(VertexBuffer.Type.valueOf(name.substring(2, name.length()))); + final String attributeUIType = getAttributeUiType(VertexBuffer.Type.valueOf(name.substring(2, name.length()))); final String glslType = uiTypeToType(attributeUIType); final ShaderNodeVariable variable = new ShaderNodeVariable(glslType, NAMESPACE, name, null, ""); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java index 6e27f36..be804b4 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveAttributeShaderNodeAction.java @@ -39,13 +39,12 @@ public RemoveAttributeShaderNodeAction(@NotNull final ShaderNodesContainer conta protected void process() { super.process(); - final ShaderNodesContainer container = getContainer(); - final TechniqueDef techniqueDef = container.getTechniqueDef(); - final ShaderNodeVariable variable = getObject(); + var container = getContainer(); + var techniqueDef = container.getTechniqueDef(); + var variable = getObject(); + var usingNodes = container.findWithRightInputVar(variable, MainShaderNodeElement.class); - final List usingNodes = container.findWithRightInputVar(variable, MainShaderNodeElement.class); - - final ShaderNodesChangeConsumer consumer = container.getChangeConsumer(); - consumer.execute(new RemoveAttributeVariableOperation(usingNodes, techniqueDef, variable, getLocation())); + container.getChangeConsumer() + .execute(new RemoveAttributeVariableOperation(usingNodes, techniqueDef, variable, getLocation())); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java index db9716e..0e895b9 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveMaterialParamShaderNodeAction.java @@ -41,16 +41,16 @@ public RemoveMaterialParamShaderNodeAction(@NotNull final ShaderNodesContainer c protected void process() { super.process(); - final ShaderNodesContainer container = getContainer(); - final MaterialDef materialDef = container.getMaterialDef(); - final TechniqueDef techniqueDef = container.getTechniqueDef(); - final ShaderNodeVariable variable = getObject(); - final MatParam matParam = materialDef.getMaterialParam(variable.getName()); + var container = getContainer(); + var materialDef = container.getMaterialDef(); + var techniqueDef = container.getTechniqueDef(); + var variable = getObject(); + var matParam = materialDef.getMaterialParam(variable.getName()); - final List usingNodes = container.findWithRightInputVar(variable, MainShaderNodeElement.class); + var usingNodes = container.findWithRightInputVar(variable, MainShaderNodeElement.class); - final ShaderNodesChangeConsumer consumer = container.getChangeConsumer(); - consumer.execute(new RemoveMaterialParameterVariableOperation(usingNodes, materialDef, techniqueDef, + container.getChangeConsumer() + .execute(new RemoveMaterialParameterVariableOperation(usingNodes, materialDef, techniqueDef, matParam, variable, getLocation())); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java index 420eb29..0275b9a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveRelationShaderNodeAction.java @@ -28,7 +28,8 @@ public class RemoveRelationShaderNodeAction extends ShaderNodeAction { public RemoveRelationShaderNodeAction(@NotNull final ShaderNodesContainer container, - @NotNull final VariableLine variableLine, @NotNull final Vector2f location) { + @NotNull final VariableLine variableLine, + @NotNull final Vector2f location) { super(container, variableLine, location); } @@ -40,31 +41,31 @@ public RemoveRelationShaderNodeAction(@NotNull final ShaderNodesContainer contai @Override @FxThread - protected void process() { + public void process() { super.process(); - final ShaderNodesContainer container = getContainer(); - final VariableLine variableLine = getObject(); + var container = getContainer(); + var variableLine = getObject(); - final ShaderNodeParameter inParameter = variableLine.getInParameter(); - final ShaderNodeElement nodeElement = inParameter.getNodeElement(); + var inParameter = variableLine.getInParameter(); + var nodeElement = inParameter.getNodeElement(); - final ShaderNodeParameter outParameter = variableLine.getOutParameter(); - final ShaderNodeElement outNodeElement = outParameter.getNodeElement(); + var outParameter = variableLine.getOutParameter(); + var outNodeElement = outParameter.getNodeElement(); - final ShaderNodesChangeConsumer consumer = container.getChangeConsumer(); + var consumer = container.getChangeConsumer(); if (nodeElement instanceof OutputGlobalShaderNodeElement && outNodeElement instanceof MainShaderNodeElement) { - final ShaderNode shaderNode = ((MainShaderNodeElement) outNodeElement).getObject(); - final VariableMapping mapping = notNull(findOutMappingByNNLeftVar(shaderNode, inParameter.getVariable())); + var shaderNode = ((MainShaderNodeElement) outNodeElement).getObject(); + var mapping = notNull(findOutMappingByNNLeftVar(shaderNode, inParameter.getVariable())); consumer.execute(new OutputDetachShaderNodeOperation(shaderNode, mapping)); } else if (nodeElement instanceof MainShaderNodeElement) { - final ShaderNode shaderNode = ((MainShaderNodeElement) nodeElement).getObject(); - final VariableMapping mapping = notNull(findInMappingByNNLeftVar(shaderNode, + var shaderNode = ((MainShaderNodeElement) nodeElement).getObject(); + var mapping = notNull(findInMappingByNNLeftVar(shaderNode, inParameter.getVariable(), shaderNode.getName())); consumer.execute(new InputDetachShaderNodeOperation(shaderNode, mapping)); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java index aed0e3a..04af47a 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveShaderNodeAction.java @@ -1,22 +1,17 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.action.remove; -import com.jme3.material.TechniqueDef; import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; -import com.jme3.shader.ShaderNodeDefinition; -import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.Messages; import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodesContainer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.ShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.remove.RemoveShaderNodeOperation; -import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.rlib.util.Utils; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; -import java.util.List; /** * The action to delete an old world param. @@ -25,7 +20,8 @@ */ public class RemoveShaderNodeAction extends ShaderNodeAction { - public RemoveShaderNodeAction(@NotNull final ShaderNodesContainer container, @NotNull final ShaderNode shaderNode, + public RemoveShaderNodeAction(@NotNull final ShaderNodesContainer container, + @NotNull final ShaderNode shaderNode, @NotNull final Vector2f location) { super(container, shaderNode, location); } @@ -41,22 +37,21 @@ public RemoveShaderNodeAction(@NotNull final ShaderNodesContainer container, @No protected void process() { super.process(); - final ShaderNodesContainer container = getContainer(); - final TechniqueDef techniqueDef = container.getTechniqueDef(); - final ShaderNode shaderNode = getObject(); + var container = getContainer(); + var techniqueDef = container.getTechniqueDef(); + var shaderNode = getObject(); + var usingNodes = new ArrayList(); - final List usingNodes = new ArrayList<>(); + var definition = shaderNode.getDefinition(); + var outputs = definition.getOutputs(); - final ShaderNodeDefinition definition = shaderNode.getDefinition(); - final List outputs = definition.getOutputs(); - - for (final ShaderNodeVariable outVar : outputs) { - final ShaderNodeVariable toFind = Utils.get(outVar::clone); + for (var outVar : outputs) { + var toFind = Utils.get(outVar::clone); toFind.setNameSpace(shaderNode.getName()); usingNodes.addAll(container.findWithRightInputVar(toFind, MainShaderNodeElement.class)); } - final ShaderNodesChangeConsumer consumer = container.getChangeConsumer(); - consumer.execute(new RemoveShaderNodeOperation(usingNodes, techniqueDef, shaderNode, getLocation())); + container.getChangeConsumer() + .execute(new RemoveShaderNodeOperation(usingNodes, techniqueDef, shaderNode, getLocation())); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java index a53a6a5..bb781aa 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/action/remove/RemoveWorldParamShaderNodeAction.java @@ -40,15 +40,14 @@ public RemoveWorldParamShaderNodeAction(@NotNull final ShaderNodesContainer cont protected void process() { super.process(); - final ShaderNodesContainer container = getContainer(); - final TechniqueDef techniqueDef = container.getTechniqueDef(); - final ShaderNodeVariable variable = getObject(); - final UniformBinding binding = UniformBinding.valueOf(variable.getName()); - - final List usingNodes = container.findWithRightInputVar(variable, MainShaderNodeElement.class); - - final ShaderNodesChangeConsumer consumer = container.getChangeConsumer(); - consumer.execute(new RemoveWorldParameterVariableOperation(usingNodes, techniqueDef, + var container = getContainer(); + var techniqueDef = container.getTechniqueDef(); + var variable = getObject(); + var binding = UniformBinding.valueOf(variable.getName()); + var usingNodes = container.findWithRightInputVar(variable, MainShaderNodeElement.class); + + container.getChangeConsumer() + .execute(new RemoveWorldParameterVariableOperation(usingNodes, techniqueDef, binding, variable, getLocation())); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java index deeba9c..b9968ec 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MainShaderNodeElement.java @@ -1,7 +1,7 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.main; import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.*; -import com.jme3.material.TechniqueDef; + import com.jme3.math.Vector2f; import com.jme3.shader.*; import com.ss.editor.annotation.FxThread; @@ -17,7 +17,6 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.InputShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.OutputShaderNodeParameter; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; -import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; import com.ss.editor.shader.nodes.ui.component.shader.nodes.tooltip.SndDocumentationTooltip; import com.ss.rlib.ui.util.FXUtils; import com.ss.rlib.util.StringUtils; @@ -26,7 +25,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; import java.util.Optional; /** @@ -55,7 +53,8 @@ public MainShaderNodeElement(@NotNull final ShaderNodesContainer container, @Not @FxThread @Override public @Nullable ShaderNodeParameter parameterFor(@NotNull final ShaderNodeVariable variable, - final boolean fromOutputMapping, final boolean input) { + final boolean fromOutputMapping, + final boolean input) { var shaderNode = getObject(); if (!shaderNode.getName().equals(variable.getNameSpace())) { @@ -84,6 +83,14 @@ protected void fillParameters(@NotNull final VBox container) { } } + @Override + public boolean canAttach(@NotNull final InputShaderNodeParameter inputParameter, + @NotNull final OutputShaderNodeParameter outputParameter) { + + return !inputParameter.isUsedExpression() && + super.canAttach(inputParameter, outputParameter); + } + @Override @FxThread public void attach(@NotNull final InputShaderNodeParameter inputParameter, @@ -125,7 +132,7 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, var outShaderNode = ((MainShaderNodeElement) nodeElement).getObject(); changeConsumer.execute(new AttachVarToShaderNodeOperation(shaderNode, newMapping, - currentMapping, techniqueDef, outShaderNode)); + currentMapping, techniqueDef, outShaderNode)); } else if (nodeElement instanceof MaterialShaderNodeElement || nodeElement instanceof WorldShaderNodeElement) { @@ -133,10 +140,11 @@ public void attach(@NotNull final InputShaderNodeParameter inputParameter, if (type == Shader.ShaderType.Vertex) { - final var fragmentNodes = container.findWithRightInputVar(newMapping.getLeftVariable(), - FragmentShaderNodeElement.class); + var fragmentNodes = container.findWithRightInputVar(newMapping.getLeftVariable(), + FragmentShaderNodeElement.class); - newMapping.getLeftVariable().setShaderOutput(!fragmentNodes.isEmpty()); + newMapping.getLeftVariable() + .setShaderOutput(!fragmentNodes.isEmpty()); } changeConsumer.execute(new AttachUniformToShaderNodeOperation(shaderNode, outVar, techniqueDef, diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java index d5d716d..f631b28 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java @@ -87,7 +87,8 @@ protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer edito } @FxThread - protected void notify(@NotNull final ShaderNodesChangeConsumer editor, @Nullable final VariableMapping oldMapping, + protected void notify(@NotNull final ShaderNodesChangeConsumer editor, + @Nullable final VariableMapping oldMapping, @Nullable final VariableMapping newMapping) { if (oldMapping != null && newMapping != null) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index c8cb099..51c8f49 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -1,20 +1,28 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter; import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_INPUT_PARAMETER; +import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.canUseExpression; + +import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.annotation.FxThread; -import com.ss.editor.manager.ExecutorManager; +import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.PluginCssClasses; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.remove.RemoveRelationShaderNodeAction; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.InputSocketElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import com.ss.editor.ui.css.CssClasses; import com.ss.rlib.ui.util.FXUtils; +import javafx.event.ActionEvent; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; import javafx.scene.layout.HBox; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The implementation of input shader nodes parameter. @@ -23,7 +31,6 @@ */ public class InputShaderNodeParameter extends ShaderNodeParameter { - /** * The check box to use expression. */ @@ -84,15 +91,30 @@ public InputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, return new InputSocketElement(this); } + /** + * Return true if this parameter uses expression. + * + * @return true if this parameter uses expression. + */ + @FxThread + public boolean isUsedExpression() { + return getUseExpression().isSelected(); + } + @Override @FxThread protected void createContent() { super.createContent(); - this.useExpressionLabel = new Label("expr:"); + this.useExpressionLabel = new Label(PluginMessages.NODE_ELEMENT_USE_EXPRESSION + ":"); this.useExpression = new CheckBox(); + this.useExpression.setDisable(!canUseExpression(getNodeElement(), getVariable())); + this.useExpression.setOnAction(this::handleChangeUseExpression); this.expressionField = new TextField(); this.expressionField.prefWidthProperty().bind(widthProperty()); + this.expressionField.setOnKeyReleased(this::handleChangeExpression); + this.expressionField.focusedProperty() + .addListener((observable, oldValue, newValue) -> handleChangeExpression(null)); var parameterContainer = new HBox(getSocket(), getNameLabel(), getTypeLabel()); parameterContainer.prefWidthProperty().bind(widthProperty()); @@ -110,4 +132,45 @@ protected void createContent() { FXUtils.addClassTo(parameterContainer, PluginCssClasses.SHADER_NODE_INPUT_PARAMETER_CONTAINER); FXUtils.addClassTo(expressionContainer, CssClasses.DEF_HBOX); } + + /** + * Handle of changing expression. + * + * @param event the key event or null. + */ + @FxThread + private void handleChangeExpression(@Nullable final KeyEvent event) { + + if (event != null && event.getCode() != KeyCode.ENTER) { + return; + } + + + } + + /** + * Handle of using expression. + * + * @param event the action event. + */ + @FxThread + private void handleChangeUseExpression(@NotNull final ActionEvent event) { + + var useExpression = getUseExpression(); + var container = getNodeElement().getContainer(); + + if (useExpression.isSelected()) { + + var line = container.findLineByInParameter(this) + .orElseThrow(() -> new IllegalStateException("Can't find a variable line for the input parameter.")); + + var action = new RemoveRelationShaderNodeAction(container, line, Vector2f.ZERO); + action.process(); + + } else { + + container.getChangeConsumer() + .execute(null); + } + } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java index c29ed21..7dde066 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java @@ -60,6 +60,13 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, FXUtils.addClassTo(socket, SHADER_NODE_PARAMETER_SOCKET); } + /** + * Refresh this parameter. + */ + @FxThread + public void refresh() { + } + /** * Get the shader nodes element. * @@ -125,13 +132,8 @@ public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, */ @FxThread protected void createContent() { - - final ShaderNodeVariable variable = getVariable(); - - final Label nameLabel = getNameLabel(); - nameLabel.setText(variable.getName()); - - final Label typeLabel = getTypeLabel(); - typeLabel.setText(variable.getType()); + var variable = getVariable(); + getNameLabel().setText(variable.getName()); + getTypeLabel().setText(variable.getType()); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java index 09cdd47..60909a6 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java @@ -1,5 +1,6 @@ package com.ss.editor.shader.nodes.util; +import static com.ss.rlib.util.dictionary.DictionaryFactory.newObjectDictionary; import static java.util.stream.Collectors.toList; import com.jme3.material.MatParam; import com.jme3.material.MaterialDef; @@ -15,6 +16,7 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.GlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.global.OutputGlobalShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.AttributeShaderNodeElement; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MainShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.MaterialShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.main.WorldShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.InputShaderNodeParameter; @@ -22,13 +24,14 @@ import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.ShaderNodeParameter; import com.ss.editor.util.GlslType; import com.ss.rlib.util.StringUtils; -import com.ss.rlib.util.dictionary.DictionaryFactory; import com.ss.rlib.util.dictionary.ObjectDictionary; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; import java.util.function.BiFunction; +import java.util.function.Supplier; +import java.util.stream.IntStream; /** * The utility class. @@ -37,9 +40,12 @@ */ public class ShaderNodeUtils { + interface NodeElementFactory extends + BiFunction> { + } + @NotNull - private static final ObjectDictionary>> NODE_ELEMENT_FACTORIES = - DictionaryFactory.newObjectDictionary(); + private static final ObjectDictionary NODE_ELEMENT_FACTORIES = newObjectDictionary(); static { NODE_ELEMENT_FACTORIES.put(MaterialShaderNodeElement.NAMESPACE, MaterialShaderNodeElement::new); @@ -48,12 +54,12 @@ public class ShaderNodeUtils { } @NotNull - private static final Set SYSTEM_NAMESPACES = new HashSet<>(Arrays.asList( + private static final Set SYSTEM_NAMESPACES = Set.of( MaterialShaderNodeElement.NAMESPACE, GlobalShaderNodeElement.NAMESPACE, WorldShaderNodeElement.NAMESPACE, AttributeShaderNodeElement.NAMESPACE - )); + ); /** * Return true of the node name is user's shader node. @@ -360,7 +366,7 @@ public static boolean hasInMappingByRightVar(@NotNull final ShaderNode shaderNod * @return the UI type. */ @FromAnyThread - public static @NotNull String getAttributeUIType(@NotNull final VertexBuffer.Type attribute) { + public static @NotNull String getAttributeUiType(@NotNull final VertexBuffer.Type attribute) { switch (attribute) { case BoneWeight: case BindPoseNormal: @@ -443,9 +449,10 @@ public static boolean hasInMappingByRightVar(@NotNull final ShaderNode shaderNod */ @FromAnyThread public static boolean containsByNN(@NotNull final Collection variables, - @NotNull final String name, @NotNull final String nameSpace) { + @NotNull final String name, + @NotNull final String nameSpace) { - for (final ShaderNodeVariable variable : variables) { + for (var variable : variables) { if (!StringUtils.equals(variable.getNameSpace(), nameSpace)) { continue; @@ -473,11 +480,11 @@ public static boolean isAccessibleType(@NotNull final String inType, @NotNull fi return inType.equals(outType); } - final String[] inTypes = inType.split("[|]"); - final String[] outTypes = outType.split("[|]"); + var inTypes = inType.split("[|]"); + var outTypes = outType.split("[|]"); - for (final String subInType : inTypes) { - for (final String subOutType : outTypes) { + for (var subInType : inTypes) { + for (var subOutType : outTypes) { if (subInType.equals(subOutType)) { return true; } @@ -496,7 +503,7 @@ public static boolean isAccessibleType(@NotNull final String inType, @NotNull fi @FromAnyThread public static boolean isRequired(@NotNull final ShaderNodeVariable variable) { - final GlslType glslType = GlslType.ofRawType(variable.getType()); + var glslType = GlslType.ofRawType(variable.getType()); switch (glslType) { case SAMPLER_2D: @@ -529,8 +536,8 @@ public static boolean isInput(@NotNull final ShaderNodeParameter parameter) { public static @NotNull String calculateRightSwizzling(@NotNull final ShaderNodeVariable leftVar, @NotNull final ShaderNodeVariable rightVar) { - final String leftType = leftVar.getType(); - final String rightType = rightVar.getType(); + var leftType = leftVar.getType(); + var rightType = rightVar.getType(); if (leftType == null || rightType == null) { return ""; @@ -618,4 +625,29 @@ public static boolean isInput(@NotNull final ShaderNodeParameter parameter) { return ""; } + + /** + * Return true if we can use expression for the node variable. + * + * @param nodeElement the node element. + * @param variable the shader node variable. + * @return true if we can use expression for the node variable. + */ + public static boolean canUseExpression(@NotNull final ShaderNodeElement nodeElement, + @NotNull final ShaderNodeVariable variable) { + + if (!(nodeElement instanceof MainShaderNodeElement)) { + return false; + } + + switch (GlslType.ofRawType(variable.getType())) { + case SAMPLER_2D: + case SAMPLER_CUBE: { + return false; + } + default: { + return true; + } + } + } } diff --git a/src/main/resources/com/ss/editor/shader/nodes/messages/messages.properties b/src/main/resources/com/ss/editor/shader/nodes/messages/messages.properties index 828e4e2..945aa14 100644 --- a/src/main/resources/com/ss/editor/shader/nodes/messages/messages.properties +++ b/src/main/resources/com/ss/editor/shader/nodes/messages/messages.properties @@ -25,6 +25,7 @@ NodeElementGlobalOutput=Global outputs NodeElementVertexAttribute=Vertex attribute NodeElementWorldParameter=World parameter NodeElementMaterialParameter=Material parameter +NodeElementUseExpression=expr TreeNodePreviewMaterialSettings=Preview material settings diff --git a/src/main/resources/com/ss/editor/shader/nodes/messages/messages_ru.properties b/src/main/resources/com/ss/editor/shader/nodes/messages/messages_ru.properties index 820821a..d97ea22 100644 --- a/src/main/resources/com/ss/editor/shader/nodes/messages/messages_ru.properties +++ b/src/main/resources/com/ss/editor/shader/nodes/messages/messages_ru.properties @@ -25,6 +25,7 @@ NodeElementGlobalOutput=Результат NodeElementVertexAttribute=Вершинный атрибут NodeElementWorldParameter=Глобальный параметр NodeElementMaterialParameter=Параметр материала +NodeElementUseExpression=выр. TreeNodePreviewMaterialSettings=Настройки материала превью diff --git a/src/main/resources/com/ss/editor/shader/nodes/style.css b/src/main/resources/com/ss/editor/shader/nodes/style.css index 3f55bed..6593c9c 100644 --- a/src/main/resources/com/ss/editor/shader/nodes/style.css +++ b/src/main/resources/com/ss/editor/shader/nodes/style.css @@ -43,7 +43,7 @@ } .shader-node-input-parameter > .label { - -fx-min-width: 40px; + -fx-min-width: 50px; -fx-alignment: center-right; } @@ -51,7 +51,6 @@ -fx-alignment: center-left; } - .shader-node-input-parameter > .hbox { -fx-padding: 1px 3px 1px 8px; -fx-alignment: center; From d420823e7b83f3cc1449b4901bc852443fd715d9 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Thu, 29 Mar 2018 17:19:31 +0300 Subject: [PATCH 18/25] continue working on value mapping. --- ...achVarExpressionToShaderNodeOperation.java | 59 +++++++++++++++++++ .../AttachVarToShaderNodeOperation.java | 55 +++++++++-------- .../parameter/InputShaderNodeParameter.java | 37 +++++++++--- .../shader/nodes/util/ShaderNodeUtils.java | 45 ++++++++++++-- 4 files changed, 157 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarExpressionToShaderNodeOperation.java diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarExpressionToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarExpressionToShaderNodeOperation.java new file mode 100644 index 0000000..a4879bb --- /dev/null +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarExpressionToShaderNodeOperation.java @@ -0,0 +1,59 @@ +package com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.attach; + +import com.jme3.shader.ShaderNode; +import com.jme3.shader.VariableMapping; +import com.ss.editor.annotation.JmeThread; +import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * The implementation of attaching a variable to a shader nodes. + * + * @author JavaSaBr + */ +public class AttachVarExpressionToShaderNodeOperation extends AttachShaderNodeOperation { + + public AttachVarExpressionToShaderNodeOperation( + @NotNull final ShaderNode shaderNode, + @Nullable final VariableMapping newMapping, + @Nullable final VariableMapping oldMapping + ) { + super(shaderNode, newMapping, oldMapping); + } + + @Override + @JmeThread + protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.redoImplInJmeThread(editor); + + var shaderNode = getShaderNode(); + var newMapping = getNewMapping(); + var inputMapping = shaderNode.getInputMapping(); + + if (getOldMapping() != null) { + inputMapping.remove(getOldMapping()); + } + + if (newMapping != null) { + inputMapping.add(newMapping); + } + } + + @Override + @JmeThread + protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { + super.undoImplInJmeThread(editor); + + var newMapping = getNewMapping(); + var inputMapping = getShaderNode().getInputMapping(); + + if (newMapping != null) { + inputMapping.remove(newMapping); + } + + if (getOldMapping() != null) { + inputMapping.add(getOldMapping()); + } + } +} diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java index 0d74c55..3b4e1bf 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarToShaderNodeOperation.java @@ -57,11 +57,13 @@ public class AttachVarToShaderNodeOperation extends AttachShaderNodeOperation { */ private boolean outShaderWasUnused; - public AttachVarToShaderNodeOperation(@NotNull final ShaderNode shaderNode, - @Nullable final VariableMapping newMapping, - @Nullable final VariableMapping oldMapping, - @NotNull final TechniqueDef techniqueDef, - @NotNull final ShaderNode outShaderNode) { + public AttachVarToShaderNodeOperation( + @NotNull final ShaderNode shaderNode, + @Nullable final VariableMapping newMapping, + @Nullable final VariableMapping oldMapping, + @NotNull final TechniqueDef techniqueDef, + @NotNull final ShaderNode outShaderNode + ) { super(shaderNode, newMapping, oldMapping); this.techniqueDef = techniqueDef; this.outShaderNode = outShaderNode; @@ -72,19 +74,19 @@ public AttachVarToShaderNodeOperation(@NotNull final ShaderNode shaderNode, protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { super.redoImplInJmeThread(editor); - final ShaderNode shaderNode = getShaderNode(); - final Shader.ShaderType inType = shaderNode.getDefinition().getType(); + var shaderNode = getShaderNode(); + var inType = shaderNode.getDefinition().getType(); - final ShaderNode outShaderNode = getOutShaderNode(); - final Shader.ShaderType outType = outShaderNode.getDefinition().getType(); + var outShaderNode = getOutShaderNode(); + var outType = outShaderNode.getDefinition().getType(); - final VariableMapping newMapping = getNewMapping(); - final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); + var newMapping = getNewMapping(); + var generationInfo = techniqueDef.getShaderGenerationInfo(); if (newMapping != null && outType == Shader.ShaderType.Vertex && inType != Shader.ShaderType.Vertex) { - final List varyings = generationInfo.getVaryings(); - final ShaderNodeVariable rightVar = newMapping.getRightVariable(); + var varyings = generationInfo.getVaryings(); + var rightVar = newMapping.getRightVariable(); if (!varyings.contains(rightVar)) { varyings.add(rightVar); @@ -97,9 +99,9 @@ protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer edit toRevertOutput.getLeftVariable().setShaderOutput(true); } - final List shaderNodes = techniqueDef.getShaderNodes(); - final int outSnIndex = shaderNodes.indexOf(outShaderNode); - final int snIndex = shaderNodes.indexOf(shaderNode); + var shaderNodes = techniqueDef.getShaderNodes(); + var outSnIndex = shaderNodes.indexOf(outShaderNode); + var snIndex = shaderNodes.indexOf(shaderNode); if (outSnIndex > snIndex) { previousShaderOrder = new ArrayList<>(shaderNodes); @@ -107,13 +109,13 @@ protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer edit shaderNodes.add(snIndex, outShaderNode); } - final List unusedNodes = generationInfo.getUnusedNodes(); + var unusedNodes = generationInfo.getUnusedNodes(); if (unusedNodes.contains(outShaderNode.getName())) { unusedNodes.remove(outShaderNode.getName()); outShaderWasUnused = true; } - final List inputMapping = shaderNode.getInputMapping(); + var inputMapping = shaderNode.getInputMapping(); if (getOldMapping() != null) { inputMapping.remove(getOldMapping()); @@ -129,11 +131,11 @@ protected void redoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer edit protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer editor) { super.undoImplInJmeThread(editor); - final VariableMapping newMapping = getNewMapping(); - final ShaderGenerationInfo generationInfo = techniqueDef.getShaderGenerationInfo(); + var newMapping = getNewMapping(); + var generationInfo = techniqueDef.getShaderGenerationInfo(); if (newMapping != null && wasAddedToVaryings) { - final List varyings = generationInfo.getVaryings(); + var varyings = generationInfo.getVaryings(); varyings.remove(newMapping.getRightVariable()); wasAddedToVaryings = false; } @@ -144,20 +146,19 @@ protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer edit } if (previousShaderOrder != null) { - final List shaderNodes = techniqueDef.getShaderNodes(); + var shaderNodes = techniqueDef.getShaderNodes(); shaderNodes.clear(); shaderNodes.addAll(previousShaderOrder); previousShaderOrder = null; } if (outShaderWasUnused) { - final List unusedNodes = generationInfo.getUnusedNodes(); + var unusedNodes = generationInfo.getUnusedNodes(); unusedNodes.add(outShaderNode.getName()); outShaderWasUnused = false; } - final List inputMapping = getShaderNode().getInputMapping(); - + var inputMapping = getShaderNode().getInputMapping(); if (newMapping != null) { inputMapping.remove(newMapping); } @@ -168,7 +169,9 @@ protected void undoImplInJmeThread(@NotNull final ShaderNodesChangeConsumer edit } /** - * @return the output shader nodes. + * Get the output shader node. + * + * @return the output shader node. */ @FromAnyThread private @NotNull ShaderNode getOutShaderNode() { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index 51c8f49..372a13b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -1,19 +1,23 @@ package com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter; import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_INPUT_PARAMETER; -import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.canUseExpression; +import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.*; import com.jme3.math.Vector2f; +import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.PluginCssClasses; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.remove.RemoveRelationShaderNodeAction; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.line.VariableLine; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.attach.AttachVarExpressionToShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.InputSocketElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; import com.ss.editor.ui.css.CssClasses; import com.ss.rlib.ui.util.FXUtils; +import com.ss.rlib.util.StringUtils; import javafx.event.ActionEvent; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; @@ -24,6 +28,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Optional; + /** * The implementation of input shader nodes parameter. * @@ -145,7 +151,20 @@ private void handleChangeExpression(@Nullable final KeyEvent event) { return; } + var element = getNodeElement(); + var shaderNode = (ShaderNode) element.getObject(); + var container = element.getContainer(); + var expressionField = getExpressionField(); + var currentExpression = expressionField.getText(); + var currentMapping = findInMappingByNLeftVar(shaderNode, getVariable()); + if (currentMapping != null && StringUtils.equals(currentExpression, currentMapping.getRightExpression())) { + return; + } + + var newMapping = makeExpressionMapping(this, currentExpression); + container.getChangeConsumer() + .execute(new AttachVarExpressionToShaderNodeOperation(shaderNode, newMapping, currentMapping)); } /** @@ -156,21 +175,21 @@ private void handleChangeExpression(@Nullable final KeyEvent event) { @FxThread private void handleChangeUseExpression(@NotNull final ActionEvent event) { + var element = getNodeElement(); + var shaderNode = (ShaderNode) element.getObject(); var useExpression = getUseExpression(); - var container = getNodeElement().getContainer(); + var container = element.getContainer(); if (useExpression.isSelected()) { - var line = container.findLineByInParameter(this) - .orElseThrow(() -> new IllegalStateException("Can't find a variable line for the input parameter.")); - - var action = new RemoveRelationShaderNodeAction(container, line, Vector2f.ZERO); - action.process(); + container.findLineByInParameter(this) + .map(line -> new RemoveRelationShaderNodeAction(container, line, Vector2f.ZERO)) + .ifPresent(RemoveRelationShaderNodeAction::process); } else { - + var currentMapping = findInMappingByNLeftVar(shaderNode, getVariable()); container.getChangeConsumer() - .execute(null); + .execute(new AttachVarExpressionToShaderNodeOperation(shaderNode, null, currentMapping)); } } } diff --git a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java index 60909a6..0057e30 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java @@ -194,8 +194,10 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, * @return the mapping or null. */ @FromAnyThread - public static @Nullable VariableMapping findInMappingByNLeftVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable) { + public static @Nullable VariableMapping findInMappingByNLeftVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable + ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByName(mapping.getLeftVariable(), variable)) .findAny().orElse(null); @@ -310,6 +312,39 @@ public static boolean hasInMappingByRightVar(@NotNull final ShaderNode shaderNod .stream().anyMatch(mapping -> equalsByNameAndNameSpace(mapping.getRightVariable(), variable)); } + /** + * Make a new mapping with the expression. + * + * @param inputParameter the input parameter. + * @param expression the expression. + * @return the new mapping. + */ + @FromAnyThread + public static @NotNull VariableMapping makeExpressionMapping( + @NotNull final InputShaderNodeParameter inputParameter, + @NotNull final String expression + ) { + + var element = inputParameter.getNodeElement(); + var object = element.getObject(); + var variable = inputParameter.getVariable(); + + final String nameSpace; + + if (object instanceof ShaderNode) { + nameSpace = ((ShaderNode) object).getName(); + } else { + nameSpace = variable.getNameSpace(); + } + + var newMapping = new VariableMapping(); + newMapping.setLeftVariable(new ShaderNodeVariable(variable.getType(), nameSpace, variable.getName(), + null, variable.getPrefix())); + newMapping.setRightExpression(expression); + + return newMapping; + } + /** * Make a new mapping between the parameters. * @@ -318,8 +353,10 @@ public static boolean hasInMappingByRightVar(@NotNull final ShaderNode shaderNod * @return the new mapping. */ @FromAnyThread - public static @NotNull VariableMapping makeMapping(@NotNull final InputShaderNodeParameter inputParameter, - @NotNull final OutputShaderNodeParameter outputParameter) { + public static @NotNull VariableMapping makeMapping( + @NotNull final InputShaderNodeParameter inputParameter, + @NotNull final OutputShaderNodeParameter outputParameter + ) { final ShaderNodeElement inElement = inputParameter.getNodeElement(); final Object inObject = inElement.getObject(); From c37ae5c5d2effa55a5920f274aadf1296c4525b2 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Fri, 30 Mar 2018 09:02:53 +0300 Subject: [PATCH 19/25] updated editing expressions. --- .../editor/ShaderNodesChangeConsumer.java | 18 ++++-- .../editor/ShaderNodesFileEditor.java | 34 +++++----- .../attach/AttachShaderNodeOperation.java | 21 ++++--- ...achVarExpressionToShaderNodeOperation.java | 6 +- .../parameter/InputShaderNodeParameter.java | 63 ++++++++++++------- 5 files changed, 83 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java index 63e1421..a1f81b6 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java @@ -9,8 +9,8 @@ import com.jme3.shader.ShaderNodeVariable; import com.jme3.shader.UniformBinding; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,7 +22,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { /** * Get the edited material definition. - * + * * @return the edited material definition. */ @FromAnyThread @@ -62,8 +62,11 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param newMapping the new variable mapping. */ @FxThread - void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping oldMapping, - @NotNull final VariableMapping newMapping); + void notifyReplacedMapping( + @NotNull final ShaderNode shaderNode, + @NotNull final VariableMapping oldMapping, + @NotNull final VariableMapping newMapping + ); /** * Notify about added the material parameter. @@ -141,8 +144,11 @@ void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final * @param width the width. */ @FxThread - void notifyChangeState(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location, - final double width); + void notifyChangeState( + @NotNull final ShaderNodeVariable variable, + @NotNull final Vector2f location, + final double width + ); /** * Notify about changed state of the shader nodes. diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index 5f18110..93e189d 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -861,75 +861,69 @@ protected void handleChangeMapping(@NotNull final ShaderNode shaderNode) { @Override @FxThread - public void notifyReplacedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping oldMapping, - @NotNull final VariableMapping newMapping) { + public void notifyReplacedMapping( + @NotNull final ShaderNode shaderNode, + @NotNull final VariableMapping oldMapping, + @NotNull final VariableMapping newMapping + ) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.refreshLines(); + handleChangeMapping(shaderNode); } @FxThread @Override public void notifyAddedMatParameter(@NotNull final MatParam matParam, @NotNull final Vector2f location) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.addMatParam(matParam, location); + getShaderNodesContainer().addMatParam(matParam, location); } @FxThread @Override public void notifyRemovedMatParameter(@NotNull final MatParam matParam) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.removeMatParam(matParam); + getShaderNodesContainer().removeMatParam(matParam); } @FxThread @Override public void notifyAddedAttribute(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.addNodeElement(variable, location); + getShaderNodesContainer().addNodeElement(variable, location); } @FxThread @Override public void notifyRemovedAttribute(@NotNull final ShaderNodeVariable variable) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.removeNodeElement(variable); + getShaderNodesContainer().removeNodeElement(variable); } @Override @FxThread public void notifyAddedWorldParameter(@NotNull final UniformBinding binding, @NotNull final Vector2f location) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.addWorldParam(binding, location); + getShaderNodesContainer().addWorldParam(binding, location); } @Override @FxThread public void notifyRemovedWorldParameter(@NotNull final UniformBinding binding) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.removeWorldParam(binding); + getShaderNodesContainer().removeWorldParam(binding); } @Override @FxThread public void notifyAddedShaderNode(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.addShaderNode(shaderNode, location); + getShaderNodesContainer().addShaderNode(shaderNode, location); } @Override @FxThread public void notifyRemovedRemovedShaderNode(@NotNull final ShaderNode shaderNode) { buildMaterial(); - final ShaderNodesContainer container = getShaderNodesContainer(); - container.removeShaderNode(shaderNode); + getShaderNodesContainer().removeShaderNode(shaderNode); } @Override diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java index f631b28..3473921 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachShaderNodeOperation.java @@ -2,10 +2,10 @@ import com.jme3.shader.ShaderNode; import com.jme3.shader.VariableMapping; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; -import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; +import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.ui.component.editor.ShaderNodesChangeConsumer; +import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.ShaderNodeOperation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,9 +34,11 @@ public class AttachShaderNodeOperation extends ShaderNodeOperation { @Nullable private final VariableMapping oldMapping; - protected AttachShaderNodeOperation(@NotNull final ShaderNode shaderNode, - @Nullable final VariableMapping newMapping, - @Nullable final VariableMapping oldMapping) { + protected AttachShaderNodeOperation( + @NotNull final ShaderNode shaderNode, + @Nullable final VariableMapping newMapping, + @Nullable final VariableMapping oldMapping + ) { this.shaderNode = shaderNode; this.newMapping = newMapping; this.oldMapping = oldMapping; @@ -87,10 +89,11 @@ protected void undoImplInFxThread(@NotNull final ShaderNodesChangeConsumer edito } @FxThread - protected void notify(@NotNull final ShaderNodesChangeConsumer editor, - @Nullable final VariableMapping oldMapping, - @Nullable final VariableMapping newMapping) { - + protected void notify( + @NotNull final ShaderNodesChangeConsumer editor, + @Nullable final VariableMapping oldMapping, + @Nullable final VariableMapping newMapping + ) { if (oldMapping != null && newMapping != null) { editor.notifyReplacedMapping(shaderNode, oldMapping, newMapping); } else if (oldMapping != null) { diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarExpressionToShaderNodeOperation.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarExpressionToShaderNodeOperation.java index a4879bb..5d7be5c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarExpressionToShaderNodeOperation.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/operation/attach/AttachVarExpressionToShaderNodeOperation.java @@ -15,9 +15,9 @@ public class AttachVarExpressionToShaderNodeOperation extends AttachShaderNodeOperation { public AttachVarExpressionToShaderNodeOperation( - @NotNull final ShaderNode shaderNode, - @Nullable final VariableMapping newMapping, - @Nullable final VariableMapping oldMapping + @NotNull final ShaderNode shaderNode, + @Nullable final VariableMapping newMapping, + @Nullable final VariableMapping oldMapping ) { super(shaderNode, newMapping, oldMapping); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index 372a13b..4592cfe 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -2,16 +2,12 @@ import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_INPUT_PARAMETER; import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.*; - -import com.jme3.math.Vector2f; import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.annotation.FxThread; import com.ss.editor.shader.nodes.PluginMessages; import com.ss.editor.shader.nodes.ui.PluginCssClasses; import com.ss.editor.shader.nodes.ui.component.shader.nodes.ShaderNodeElement; -import com.ss.editor.shader.nodes.ui.component.shader.nodes.action.remove.RemoveRelationShaderNodeAction; -import com.ss.editor.shader.nodes.ui.component.shader.nodes.line.VariableLine; import com.ss.editor.shader.nodes.ui.component.shader.nodes.operation.attach.AttachVarExpressionToShaderNodeOperation; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.InputSocketElement; import com.ss.editor.shader.nodes.ui.component.shader.nodes.parameter.socket.SocketElement; @@ -28,8 +24,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Optional; - /** * The implementation of input shader nodes parameter. * @@ -55,8 +49,10 @@ public class InputShaderNodeParameter extends ShaderNodeParameter { @NotNull private TextField expressionField; - public InputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, - @NotNull final ShaderNodeVariable variable) { + public InputShaderNodeParameter( + @NotNull final ShaderNodeElement nodeElement, + @NotNull final ShaderNodeVariable variable + ) { super(nodeElement, variable); FXUtils.addClassTo(this, SHADER_NODE_INPUT_PARAMETER); } @@ -147,7 +143,7 @@ protected void createContent() { @FxThread private void handleChangeExpression(@Nullable final KeyEvent event) { - if (event != null && event.getCode() != KeyCode.ENTER) { + if (isDisable() || event != null && event.getCode() != KeyCode.ENTER) { return; } @@ -155,16 +151,42 @@ private void handleChangeExpression(@Nullable final KeyEvent event) { var shaderNode = (ShaderNode) element.getObject(); var container = element.getContainer(); var expressionField = getExpressionField(); - var currentExpression = expressionField.getText(); - var currentMapping = findInMappingByNLeftVar(shaderNode, getVariable()); - if (currentMapping != null && StringUtils.equals(currentExpression, currentMapping.getRightExpression())) { + var expr = expressionField.getText(); + var mapping = findInMappingByNLeftVar(shaderNode, getVariable()); + + if (mapping == null && StringUtils.isEmpty(expr)) { + return; + } else if (mapping != null && StringUtils.equals(expr, mapping.getRightExpression())) { return; } - var newMapping = makeExpressionMapping(this, currentExpression); + var newMapping = makeExpressionMapping(this, expr); container.getChangeConsumer() - .execute(new AttachVarExpressionToShaderNodeOperation(shaderNode, newMapping, currentMapping)); + .execute(new AttachVarExpressionToShaderNodeOperation(shaderNode, newMapping, mapping)); + + setDisable(true); + } + + @Override + public void refresh() { + super.refresh(); + + var element = getNodeElement(); + var object = element.getObject(); + + if (object instanceof ShaderNode) { + + var shaderNode = (ShaderNode) element.getObject(); + var mapping = findInMappingByNLeftVar(shaderNode, getVariable()); + var selected = mapping != null && mapping.getRightExpression() != null; + var expression = mapping != null ? mapping.getRightExpression() : ""; + + getUseExpression().setSelected(selected); + getExpressionField().setText(expression); + } + + setDisable(false); } /** @@ -179,17 +201,16 @@ private void handleChangeUseExpression(@NotNull final ActionEvent event) { var shaderNode = (ShaderNode) element.getObject(); var useExpression = getUseExpression(); var container = element.getContainer(); + var mapping = findInMappingByNLeftVar(shaderNode, getVariable()); + var expression = getExpressionField().getText(); if (useExpression.isSelected()) { - - container.findLineByInParameter(this) - .map(line -> new RemoveRelationShaderNodeAction(container, line, Vector2f.ZERO)) - .ifPresent(RemoveRelationShaderNodeAction::process); - + var newMapping = makeExpressionMapping(this, expression); + container.getChangeConsumer() + .execute(new AttachVarExpressionToShaderNodeOperation(shaderNode, newMapping, mapping)); } else { - var currentMapping = findInMappingByNLeftVar(shaderNode, getVariable()); container.getChangeConsumer() - .execute(new AttachVarExpressionToShaderNodeOperation(shaderNode, null, currentMapping)); + .execute(new AttachVarExpressionToShaderNodeOperation(shaderNode, null, mapping)); } } } From 9e161e3dc56adcd23404694988cbfa5ad6fd294d Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Fri, 30 Mar 2018 11:11:21 +0300 Subject: [PATCH 20/25] implemented editing of shader values. --- .../shader/nodes/ui/PluginCssClasses.java | 1 + .../parameter/InputShaderNodeParameter.java | 87 ++++++++++++------- .../com/ss/editor/shader/nodes/style.css | 8 +- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java b/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java index d5d8c20..3b3e373 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/PluginCssClasses.java @@ -15,6 +15,7 @@ public interface PluginCssClasses { @NotNull String SHADER_NODE_PARAMETER = "shader-node-parameter"; @NotNull String SHADER_NODE_INPUT_PARAMETER = "shader-node-input-parameter"; @NotNull String SHADER_NODE_INPUT_PARAMETER_CONTAINER = "shader-node-input-parameter-container"; + @NotNull String SHADER_NODE_INPUT_PARAMETER_EXPR_LABEL = "shader-node-input-parameter-expr-label"; @NotNull String SHADER_NODE_OUTPUT_PARAMETER = "shader-node-output-parameter"; @NotNull String SHADER_NODE_MATERIAL_OUTPUT_PARAMETER = "shader-node-material-output-parameter"; @NotNull String SHADER_NODE_PARAMETER_SOCKET = "shader-node-parameter-socket"; diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index 4592cfe..153a69c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -2,6 +2,8 @@ import static com.ss.editor.shader.nodes.ui.PluginCssClasses.SHADER_NODE_INPUT_PARAMETER; import static com.ss.editor.shader.nodes.util.ShaderNodeUtils.*; +import static com.ss.rlib.util.ObjectUtils.notNull; + import com.jme3.shader.ShaderNode; import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.annotation.FxThread; @@ -34,19 +36,19 @@ public class InputShaderNodeParameter extends ShaderNodeParameter { /** * The check box to use expression. */ - @NotNull + @Nullable private CheckBox useExpression; /** * The label to use an expression. */ - @NotNull + @Nullable private Label useExpressionLabel; /** * The field with expression. */ - @NotNull + @Nullable private TextField expressionField; public InputShaderNodeParameter( @@ -64,7 +66,7 @@ public InputShaderNodeParameter( */ @FxThread protected @NotNull CheckBox getUseExpression() { - return useExpression; + return notNull(useExpression); } /** @@ -74,7 +76,7 @@ public InputShaderNodeParameter( */ @FxThread protected @NotNull Label getUseExpressionLabel() { - return useExpressionLabel; + return notNull(useExpressionLabel); } /** @@ -84,7 +86,7 @@ public InputShaderNodeParameter( */ @FxThread protected @NotNull TextField getExpressionField() { - return expressionField; + return notNull(expressionField); } @Override @@ -108,31 +110,48 @@ public boolean isUsedExpression() { protected void createContent() { super.createContent(); - this.useExpressionLabel = new Label(PluginMessages.NODE_ELEMENT_USE_EXPRESSION + ":"); - this.useExpression = new CheckBox(); - this.useExpression.setDisable(!canUseExpression(getNodeElement(), getVariable())); - this.useExpression.setOnAction(this::handleChangeUseExpression); - this.expressionField = new TextField(); - this.expressionField.prefWidthProperty().bind(widthProperty()); - this.expressionField.setOnKeyReleased(this::handleChangeExpression); - this.expressionField.focusedProperty() - .addListener((observable, oldValue, newValue) -> handleChangeExpression(null)); - - var parameterContainer = new HBox(getSocket(), getNameLabel(), getTypeLabel()); - parameterContainer.prefWidthProperty().bind(widthProperty()); - - var expressionContainer = new HBox(expressionField); - expressionContainer.managedProperty().bind(useExpression.selectedProperty()); - expressionContainer.visibleProperty().bind(useExpression.selectedProperty()); - expressionContainer.prefWidthProperty().bind(widthProperty()); - - add(parameterContainer, 0, 0); - add(getUseExpressionLabel(), 1, 0); - add(getUseExpression(), 2, 0); - add(expressionContainer, 0, 1, 3, 1); - - FXUtils.addClassTo(parameterContainer, PluginCssClasses.SHADER_NODE_INPUT_PARAMETER_CONTAINER); - FXUtils.addClassTo(expressionContainer, CssClasses.DEF_HBOX); + if (canUseExpression(getNodeElement(), getVariable())) { + + var element = getNodeElement(); + var shaderNode = (ShaderNode) element.getObject(); + var mapping = findInMappingByNLeftVar(shaderNode, getVariable()); + var selected = mapping != null && mapping.getRightExpression() != null; + var expression = mapping != null ? mapping.getRightExpression() : ""; + + useExpressionLabel = new Label(PluginMessages.NODE_ELEMENT_USE_EXPRESSION + ":"); + useExpression = new CheckBox(); + useExpression.setOnAction(this::handleChangeUseExpression); + useExpression.setSelected(selected); + expressionField = new TextField(expression); + expressionField.prefWidthProperty().bind(widthProperty()); + expressionField.setOnKeyReleased(this::handleChangeExpression); + expressionField.focusedProperty() + .addListener((observable, oldValue, newValue) -> handleChangeExpression(null)); + + var parameterContainer = new HBox(getSocket(), getNameLabel(), getTypeLabel()); + parameterContainer.prefWidthProperty().bind(widthProperty()); + + getSocket().disableProperty().bind(useExpression.selectedProperty()); + + var expressionContainer = new HBox(expressionField); + expressionContainer.managedProperty().bind(useExpression.selectedProperty()); + expressionContainer.visibleProperty().bind(useExpression.selectedProperty()); + expressionContainer.prefWidthProperty().bind(widthProperty()); + + add(parameterContainer, 0, 0); + add(getUseExpressionLabel(), 1, 0); + add(getUseExpression(), 2, 0); + add(expressionContainer, 0, 1, 3, 1); + + FXUtils.addClassTo(useExpressionLabel, PluginCssClasses.SHADER_NODE_INPUT_PARAMETER_EXPR_LABEL); + FXUtils.addClassTo(parameterContainer, PluginCssClasses.SHADER_NODE_INPUT_PARAMETER_CONTAINER); + FXUtils.addClassTo(expressionContainer, CssClasses.DEF_HBOX); + + } else { + add(getSocket(), 0, 0); + add(getNameLabel(), 1, 0); + add(getTypeLabel(), 2, 0); + } } /** @@ -180,10 +199,12 @@ public void refresh() { var shaderNode = (ShaderNode) element.getObject(); var mapping = findInMappingByNLeftVar(shaderNode, getVariable()); var selected = mapping != null && mapping.getRightExpression() != null; - var expression = mapping != null ? mapping.getRightExpression() : ""; getUseExpression().setSelected(selected); - getExpressionField().setText(expression); + + if (mapping != null) { + getExpressionField().setText(mapping.getRightExpression()); + } } setDisable(false); diff --git a/src/main/resources/com/ss/editor/shader/nodes/style.css b/src/main/resources/com/ss/editor/shader/nodes/style.css index 6593c9c..873cc25 100644 --- a/src/main/resources/com/ss/editor/shader/nodes/style.css +++ b/src/main/resources/com/ss/editor/shader/nodes/style.css @@ -40,15 +40,17 @@ .shader-node-input-parameter { -fx-alignment: center-left; -fx-padding: 0px 0px 0px -4px; + -fx-hgap: 2px; } -.shader-node-input-parameter > .label { +.shader-node-input-parameter-expr-label { -fx-min-width: 50px; -fx-alignment: center-right; } .shader-node-input-parameter-container { -fx-alignment: center-left; + -fx-spacing: 2px; } .shader-node-input-parameter > .hbox { @@ -92,6 +94,10 @@ -fx-background-color: -fx-focus-color; } +.shader-node-parameter-input-socket:disabled { + -fx-opacity: -var-disabled-opacity; +} + .shader-node-parameter-output-socket:hover { -fx-background-color: -fx-focus-color; } From 541a9b12dedb711f36a7d5f23ce8aa09b1dcce39 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Fri, 30 Mar 2018 18:37:02 +0300 Subject: [PATCH 21/25] updated util class. --- .../shader/nodes/util/ShaderNodeUtils.java | 113 ++++++++++++------ 1 file changed, 74 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java index 0057e30..17c5987 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java @@ -67,7 +67,7 @@ interface NodeElementFactory extends * @param shaderNodeName the shader node name. * @return true of the node name is user's shader node. */ - public static boolean isUserShaderNode(@NotNull final String shaderNodeName) { + public static boolean isUserShaderNode(@NotNull final String shaderNodeName) {> return !SYSTEM_NAMESPACES.contains(shaderNodeName); } @@ -78,10 +78,12 @@ public static boolean isUserShaderNode(@NotNull final String shaderNodeName) { * @param var the shader node variable. * @return the option of shader node element. */ - public static @NotNull Optional> createNodeElement(@NotNull final ShaderNodesContainer container, - @NotNull final ShaderNodeVariable var) { + public static @NotNull Optional> createNodeElement( + @NotNull final ShaderNodesContainer container, + @NotNull final ShaderNodeVariable var + ) { return NODE_ELEMENT_FACTORIES.getOptional(var.getNameSpace()) - .map(factory -> factory.apply(container, var)); + .map(factory -> factory.apply(container, var)); } /** @@ -92,8 +94,10 @@ public static boolean isUserShaderNode(@NotNull final String shaderNodeName) { * @return the shader nodes or null. */ @FromAnyThread - public static @Nullable MatParam findMatParameterByName(@NotNull final MaterialDef materialDef, - @NotNull final String name) { + public static @Nullable MatParam findMatParameterByName( + @NotNull final MaterialDef materialDef, + @NotNull final String name + ) { return materialDef.getMaterialParams().stream() .filter(matParam -> matParam.getName().equals(name)) .findAny().orElse(null); @@ -107,8 +111,10 @@ public static boolean isUserShaderNode(@NotNull final String shaderNodeName) { * @return the shader nodes or null. */ @FromAnyThread - public static @Nullable UniformBinding findWorldBindingByName(@NotNull final TechniqueDef techniqueDef, - @NotNull final String name) { + public static @Nullable UniformBinding findWorldBindingByName( + @NotNull final TechniqueDef techniqueDef, + @NotNull final String name + ) { return techniqueDef.getWorldBindings().stream() .filter(binding -> binding.name().equals(name)) .findAny().orElse(null); @@ -122,8 +128,10 @@ public static boolean isUserShaderNode(@NotNull final String shaderNodeName) { * @return the shader nodes or null. */ @FromAnyThread - public static @Nullable ShaderNodeVariable findAttributeByName(@NotNull final TechniqueDef techniqueDef, - @NotNull final String name) { + public static @Nullable ShaderNodeVariable findAttributeByName( + @NotNull final TechniqueDef techniqueDef, + @NotNull final String name + ) { return techniqueDef.getShaderGenerationInfo().getAttributes().stream() .filter(variable -> variable.getName().equals(name)) .findAny().orElse(null); @@ -137,8 +145,10 @@ public static boolean isUserShaderNode(@NotNull final String shaderNodeName) { * @return the shader nodes or null. */ @FromAnyThread - public static @Nullable ShaderNode findByName(@NotNull final TechniqueDef techniqueDef, - @NotNull final String name) { + public static @Nullable ShaderNode findByName( + @NotNull final TechniqueDef techniqueDef, + @NotNull final String name + ) { return techniqueDef.getShaderNodes().stream() .filter(shaderNode -> shaderNode.getName().equals(name)) .findAny().orElse(null); @@ -152,8 +162,10 @@ public static boolean isUserShaderNode(@NotNull final String shaderNodeName) { * @return true of the variables are equal. */ @FromAnyThread - public static boolean equalsByNameAndNameSpace(@NotNull final ShaderNodeVariable first, - @NotNull final ShaderNodeVariable second) { + public static boolean equalsByNameAndNameSpace( + @NotNull final ShaderNodeVariable first, + @NotNull final ShaderNodeVariable second + ) { return StringUtils.equals(first.getName(), second.getName()) && StringUtils.equals(first.getNameSpace(), second.getNameSpace()); } @@ -166,8 +178,10 @@ public static boolean equalsByNameAndNameSpace(@NotNull final ShaderNodeVariable * @return true of the variables are equal. */ @FromAnyThread - public static boolean equalsByName(@NotNull final ShaderNodeVariable first, - @NotNull final ShaderNodeVariable second) { + public static boolean equalsByName( + @NotNull final ShaderNodeVariable first, + @NotNull final ShaderNodeVariable second + ) { return StringUtils.equals(first.getName(), second.getName()); } @@ -179,8 +193,10 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, * @return the mapping or null. */ @FromAnyThread - public static @Nullable VariableMapping findOutMappingByNNLeftVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable) { + public static @Nullable VariableMapping findOutMappingByNNLeftVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable + ) { return shaderNode.getOutputMapping().stream() .filter(mapping -> equalsByNameAndNameSpace(mapping.getLeftVariable(), variable)) .findAny().orElse(null); @@ -203,6 +219,7 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, .findAny().orElse(null); } + /** * Find an input mapping with the right variable by the name and the namespace. * @@ -211,8 +228,10 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, * @return the mapping or null. */ @FromAnyThread - public static @Nullable VariableMapping findInMappingByNNRightVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable) { + public static @Nullable VariableMapping findInMappingByNNRightVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable + ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByNameAndNameSpace(mapping.getRightVariable(), variable)) .findAny().orElse(null); @@ -226,8 +245,10 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, * @return the mapping or null. */ @FromAnyThread - public static @NotNull List findInMappingsByNNRightVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable) { + public static @NotNull List findInMappingsByNNRightVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable + ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByNameAndNameSpace(mapping.getRightVariable(), variable)) .collect(toList()); @@ -242,9 +263,11 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, * @return the mapping or null. */ @FromAnyThread - public static @NotNull List findInMappingsByNNRightVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable, - @NotNull final String nameSpace) { + public static @NotNull List findInMappingsByNNRightVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable, + @NotNull final String nameSpace + ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByName(mapping.getRightVariable(), variable)) .filter(mapping -> mapping.getRightVariable().getNameSpace().equals(nameSpace)) @@ -259,8 +282,10 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, * @return the mapping or null. */ @FromAnyThread - public static @Nullable VariableMapping findInMappingByNNLeftVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable) { + public static @Nullable VariableMapping findInMappingByNNLeftVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable + ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByNameAndNameSpace(mapping.getLeftVariable(), variable)) .findAny().orElse(null); @@ -275,9 +300,11 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, * @return the mapping or null. */ @FromAnyThread - public static @Nullable VariableMapping findInMappingByNNLeftVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable, - @NotNull final String nameSpace) { + public static @Nullable VariableMapping findInMappingByNNLeftVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable, + @NotNull final String nameSpace + ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByName(mapping.getLeftVariable(), variable)) .filter(mapping -> mapping.getLeftVariable().getNameSpace().equals(nameSpace)) @@ -292,8 +319,10 @@ public static boolean equalsByName(@NotNull final ShaderNodeVariable first, * @return true if the shader node has the output mapping with the left variable. */ @FromAnyThread - public static boolean hasOutMappingByLeftVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable) { + public static boolean hasOutMappingByLeftVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable + ) { return shaderNode.getOutputMapping() .stream().anyMatch(mapping -> equalsByNameAndNameSpace(mapping.getLeftVariable(), variable)); } @@ -306,8 +335,10 @@ public static boolean hasOutMappingByLeftVar(@NotNull final ShaderNode shaderNod * @return true if the shader nodes has the input mapping with the right variable. */ @FromAnyThread - public static boolean hasInMappingByRightVar(@NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable) { + public static boolean hasInMappingByRightVar( + @NotNull final ShaderNode shaderNode, + @NotNull final ShaderNodeVariable variable + ) { return shaderNode.getInputMapping() .stream().anyMatch(mapping -> equalsByNameAndNameSpace(mapping.getRightVariable(), variable)); } @@ -485,9 +516,11 @@ public static boolean hasInMappingByRightVar(@NotNull final ShaderNode shaderNod * @return true of the list contains it. */ @FromAnyThread - public static boolean containsByNN(@NotNull final Collection variables, - @NotNull final String name, - @NotNull final String nameSpace) { + public static boolean containsByNN( + @NotNull final Collection variables, + @NotNull final String name, + @NotNull final String nameSpace + ) { for (var variable : variables) { @@ -670,8 +703,10 @@ public static boolean isInput(@NotNull final ShaderNodeParameter parameter) { * @param variable the shader node variable. * @return true if we can use expression for the node variable. */ - public static boolean canUseExpression(@NotNull final ShaderNodeElement nodeElement, - @NotNull final ShaderNodeVariable variable) { + public static boolean canUseExpression( + @NotNull final ShaderNodeElement nodeElement, + @NotNull final ShaderNodeVariable variable + ) { if (!(nodeElement instanceof MainShaderNodeElement)) { return false; From 7e04bde6fef0fc1e62986608e2e30e82134aebeb Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Tue, 3 Apr 2018 17:58:30 +0300 Subject: [PATCH 22/25] fixed working with value mapping. --- build.gradle | 2 +- .../materialdef/J3mdTechniqueDefWriter.java | 7 +-- .../nodes/main/MaterialShaderNodeElement.java | 53 +++++++++---------- .../EditableMaterialShaderNodeParameter.java | 22 ++++---- .../parameter/InputShaderNodeParameter.java | 10 ++-- .../parameter/OutputShaderNodeParameter.java | 3 +- .../nodes/parameter/ShaderNodeParameter.java | 3 +- .../parameter/socket/InputSocketElement.java | 8 +-- .../parameter/socket/OutputSocketElement.java | 16 +++--- .../nodes/parameter/socket/SocketElement.java | 10 ++-- .../shader/nodes/util/ShaderNodeUtils.java | 2 +- 11 files changed, 69 insertions(+), 67 deletions(-) diff --git a/build.gradle b/build.gradle index 98e3b46..778a585 100644 --- a/build.gradle +++ b/build.gradle @@ -175,4 +175,4 @@ run.dependsOn { preparePlugin } -run.jvmArgs(Arrays.asList("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005")) +run.jvmArgs(Arrays.asList("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005", "-Duser.country=EU", "-Duser.language=en")) diff --git a/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java b/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java index eabfda1..8a76e86 100644 --- a/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java +++ b/src/main/java/com/jme3/material/plugin/export/materialdef/J3mdTechniqueDefWriter.java @@ -193,9 +193,10 @@ private void writeShaderNode( OutputStreamWriter out, ShaderNode shaderNode, Col out.write(" }\n"); } - private void writeVariableMapping(final OutputStreamWriter out, final ShaderNode shaderNode, - final VariableMapping mapping, final Collection matParams) - throws IOException { + private void writeVariableMapping(OutputStreamWriter out, + ShaderNode shaderNode, + VariableMapping mapping, + Collection matParams) throws IOException { final ShaderNodeVariable leftVar = mapping.getLeftVariable(); final ShaderNodeVariable rightVar = mapping.getRightVariable(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java index 8300194..76012fc 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/main/MaterialShaderNodeElement.java @@ -42,16 +42,15 @@ public class MaterialShaderNodeElement extends OutputVariableShaderNodeElement { * @return the shader nodes variable. */ @FromAnyThread - public static @NotNull ShaderNodeVariable toVariable(@NotNull final MatParam matParam) { - final VarType type = matParam.getVarType(); - final String glslType = type.getGlslType(); - final String resultType = glslType.contains("|") ? glslType.split("[|]")[0] : glslType; + public static @NotNull ShaderNodeVariable toVariable(@NotNull MatParam matParam) { + var type = matParam.getVarType(); + var glslType = type.getGlslType(); + var resultType = glslType.contains("|") ? glslType.split("[|]")[0] : glslType; return new ShaderNodeVariable(resultType, NAMESPACE, matParam.getName(), null, "m_"); } - public MaterialShaderNodeElement(@NotNull final ShaderNodesContainer container, - @NotNull final ShaderNodeVariable variable) { + public MaterialShaderNodeElement(@NotNull ShaderNodesContainer container, @NotNull ShaderNodeVariable variable) { super(container, variable); } @@ -59,12 +58,12 @@ public MaterialShaderNodeElement(@NotNull final ShaderNodesContainer container, @FxThread protected @NotNull OutputShaderNodeParameter newParameter() { - final ShaderNodeVariable variable = getObject(); - final ShaderNodesContainer container = getContainer(); - final MaterialDef materialDef = container.getMaterialDef(); - final MatParam materialParam = materialDef.getMaterialParam(variable.getName()); + var variable = getObject(); + var container = getContainer(); + var materialDef = container.getMaterialDef(); + var materialParam = materialDef.getMaterialParam(variable.getName()); - final PropertyControl control = buildControl(container.getChangeConsumer(), materialParam); + var control = buildControl(container.getChangeConsumer(), materialParam); if (control == null) { return super.newParameter(); } @@ -93,13 +92,14 @@ public void notifyChangedMaterial() { getParametersContainer().getChildren().stream() .filter(EditableMaterialShaderNodeParameter.class::isInstance) .map(EditableMaterialShaderNodeParameter.class::cast) - .forEach(EditableMaterialShaderNodeParameter::sync); + .forEach(EditableMaterialShaderNodeParameter::requestLayout); } @FxThread - private @Nullable PropertyControl buildControl(@NotNull final ChangeConsumer consumer, - @NotNull final MatParam param) { - + private @Nullable PropertyControl buildControl( + @NotNull ChangeConsumer consumer, + @NotNull MatParam param + ) { switch (param.getVarType()) { case Boolean: { @@ -139,32 +139,31 @@ public void notifyChangedMaterial() { } @FxThread - private T getCurrentValue(@NotNull final MatParam matParam) { - - final ShaderNodesChangeConsumer changeConsumer = getContainer().getChangeConsumer(); - final Material material = changeConsumer.getPreviewMaterial(); + private T getCurrentValue(@NotNull MatParam matParam) { + var changeConsumer = getContainer().getChangeConsumer(); + var material = changeConsumer.getPreviewMaterial(); if (material == null) { return null; } - final MatParam param = material.getParam(matParam.getName()); - final T value = param == null ? null : unsafeCast(param.getValue()); + var param = material.getParam(matParam.getName()); + T value = param == null ? null : unsafeCast(param.getValue()); if (value instanceof Vector4f) { - final Vector4f vector4f = (Vector4f) value; - return unsafeCast(new ColorRGBA(vector4f.getX(), vector4f.getY(), vector4f.getZ(), vector4f.getW())); + var vector4f = (Vector4f) value; + return unsafeCast(new ColorRGBA(vector4f.getX(), vector4f.getY(), + vector4f.getZ(), vector4f.getW())); } return value; } @JmeThread - private void applyValue(@NotNull final MatParam matParam, @Nullable T value) { - - final ShaderNodesChangeConsumer changeConsumer = getContainer().getChangeConsumer(); - final Material material = changeConsumer.getPreviewMaterial(); + private void applyValue(@NotNull MatParam matParam, @Nullable T value) { + var changeConsumer = getContainer().getChangeConsumer(); + var material = changeConsumer.getPreviewMaterial(); if (material == null) { return; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java index 1d23261..dcb1667 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/EditableMaterialShaderNodeParameter.java @@ -25,24 +25,26 @@ public class EditableMaterialShaderNodeParameter extends OutputShaderNodeParamet @NotNull private final PropertyControl propertyControl; - public EditableMaterialShaderNodeParameter(@NotNull final MaterialShaderNodeElement nodeElement, - @NotNull final ShaderNodeVariable variable, - @NotNull final PropertyControl propertyControl) { + public EditableMaterialShaderNodeParameter( + @NotNull MaterialShaderNodeElement nodeElement, + @NotNull ShaderNodeVariable variable, + @NotNull PropertyControl propertyControl + ) { super(nodeElement, variable); this.propertyControl = propertyControl; propertyControl.prefWidthProperty().bind(widthProperty()); - FXUtils.addToPane(propertyControl, this); - FXUtils.addToPane(getSocket(), this); + add(propertyControl, 0, 0); + add(getSocket(), 1, 0); + FXUtils.addClassTo(this, SHADER_NODE_MATERIAL_OUTPUT_PARAMETER); + refresh(); } - /** - * Sync the current value of this parameter. - */ - @FxThread - public void sync() { + @Override + public void refresh() { + super.refresh(); propertyControl.sync(); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java index 153a69c..4cb7f37 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/InputShaderNodeParameter.java @@ -51,10 +51,7 @@ public class InputShaderNodeParameter extends ShaderNodeParameter { @Nullable private TextField expressionField; - public InputShaderNodeParameter( - @NotNull final ShaderNodeElement nodeElement, - @NotNull final ShaderNodeVariable variable - ) { + public InputShaderNodeParameter(@NotNull ShaderNodeElement nodeElement, @NotNull ShaderNodeVariable variable) { super(nodeElement, variable); FXUtils.addClassTo(this, SHADER_NODE_INPUT_PARAMETER); } @@ -160,7 +157,7 @@ protected void createContent() { * @param event the key event or null. */ @FxThread - private void handleChangeExpression(@Nullable final KeyEvent event) { + private void handleChangeExpression(@Nullable KeyEvent event) { if (isDisable() || event != null && event.getCode() != KeyCode.ENTER) { return; @@ -216,7 +213,7 @@ public void refresh() { * @param event the action event. */ @FxThread - private void handleChangeUseExpression(@NotNull final ActionEvent event) { + private void handleChangeUseExpression(@NotNull ActionEvent event) { var element = getNodeElement(); var shaderNode = (ShaderNode) element.getObject(); @@ -224,6 +221,7 @@ private void handleChangeUseExpression(@NotNull final ActionEvent event) { var container = element.getContainer(); var mapping = findInMappingByNLeftVar(shaderNode, getVariable()); var expression = getExpressionField().getText(); + expression = expression == null ? "" : expression; if (useExpression.isSelected()) { var newMapping = makeExpressionMapping(this, expression); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java index 141f01e..257443b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/OutputShaderNodeParameter.java @@ -16,8 +16,7 @@ */ public class OutputShaderNodeParameter extends ShaderNodeParameter { - public OutputShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, - @NotNull final ShaderNodeVariable variable) { + public OutputShaderNodeParameter(@NotNull ShaderNodeElement nodeElement, @NotNull ShaderNodeVariable variable) { super(nodeElement, variable); FXUtils.addClassTo(this, SHADER_NODE_OUTPUT_PARAMETER); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java index 7dde066..ee01fc3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/ShaderNodeParameter.java @@ -48,8 +48,7 @@ public class ShaderNodeParameter extends GridPane { @NotNull private final Label typeLabel; - public ShaderNodeParameter(@NotNull final ShaderNodeElement nodeElement, - @NotNull final ShaderNodeVariable variable) { + public ShaderNodeParameter(@NotNull ShaderNodeElement nodeElement, @NotNull ShaderNodeVariable variable) { this.nodeElement = nodeElement; this.variable = variable; this.socket = createSocket(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java index 68bd7cf..de76c14 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/InputSocketElement.java @@ -74,7 +74,7 @@ public String getName() { } }; - public InputSocketElement(@NotNull final ShaderNodeParameter parameter) { + public InputSocketElement(@NotNull ShaderNodeParameter parameter) { super(parameter); setOnDragOver(this::handleDragOver); setOnDragDropped(this::handleDragDropped); @@ -89,7 +89,7 @@ public InputSocketElement(@NotNull final ShaderNodeParameter parameter) { * @param dragEvent the drag event. */ @FxThread - private void handleDragExited(@NotNull final DragEvent dragEvent) { + private void handleDragExited(@NotNull DragEvent dragEvent) { droppable.setValue(false); } @@ -99,7 +99,7 @@ private void handleDragExited(@NotNull final DragEvent dragEvent) { * @param dragEvent the drag event. */ @FxThread - private void handleDragDropped(@NotNull final DragEvent dragEvent) { + private void handleDragDropped(@NotNull DragEvent dragEvent) { droppable.setValue(false); var parameter = (InputShaderNodeParameter) getParameter(); @@ -126,7 +126,7 @@ private void handleDragDropped(@NotNull final DragEvent dragEvent) { * @param dragEvent the drag event. */ @FxThread - private void handleDragOver(@NotNull final DragEvent dragEvent) { + private void handleDragOver(@NotNull DragEvent dragEvent) { var parameter = (InputShaderNodeParameter) getParameter(); var nodeElement = parameter.getNodeElement(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java index 632a6f2..95b2d74 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/OutputSocketElement.java @@ -48,7 +48,7 @@ public String getName() { } }; - public OutputSocketElement(@NotNull final ShaderNodeParameter parameter) { + public OutputSocketElement(@NotNull ShaderNodeParameter parameter) { super(parameter); setOnDragDetected(this::handleStartDrag); setOnDragDone(this::handleStopDrag); @@ -59,19 +59,19 @@ public OutputSocketElement(@NotNull final ShaderNodeParameter parameter) { /** * Handle dragging. * - * @param mouseEvent the mouse event. + * @param event the mouse event. */ @FxThread - private void handleMouseDragged(@NotNull final MouseEvent mouseEvent) { + private void handleMouseDragged(@NotNull MouseEvent event) { var container = getParameter() .getNodeElement() .getContainer(); container.startAttaching(this); - container.updateAttaching(mouseEvent.getSceneX(), mouseEvent.getSceneY()); + container.updateAttaching(event.getSceneX(), event.getSceneY()); - mouseEvent.consume(); + event.consume(); } /** @@ -80,7 +80,7 @@ private void handleMouseDragged(@NotNull final MouseEvent mouseEvent) { * @param dragEvent the drag event. */ @FxThread - private void handleStopDrag(@NotNull final DragEvent dragEvent) { + private void handleStopDrag(@NotNull DragEvent dragEvent) { setCursor(Cursor.DEFAULT); getParameter().getNodeElement() @@ -98,7 +98,7 @@ private void handleStopDrag(@NotNull final DragEvent dragEvent) { * @param mouseEvent the mouse event. */ @FxThread - private void handleStartDrag(@NotNull final MouseEvent mouseEvent) { + private void handleStartDrag(@NotNull MouseEvent mouseEvent) { setCursor(Cursor.MOVE); var content = new ClipboardContent(); @@ -109,11 +109,13 @@ private void handleStartDrag(@NotNull final MouseEvent mouseEvent) { var parameter = getParameter(); var nodeElement = parameter.getNodeElement(); + var container = nodeElement.getContainer(); container.startAttaching(this); container.updateAttaching(mouseEvent.getSceneX(), mouseEvent.getSceneY()); dragged.setValue(true); + mouseEvent.consume(); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java index 683ac60..b330365 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/shader/nodes/parameter/socket/SocketElement.java @@ -42,7 +42,7 @@ public class SocketElement extends Pane { @NotNull private final ShaderNodeParameter parameter; - public SocketElement(@NotNull final ShaderNodeParameter parameter) { + public SocketElement(@NotNull ShaderNodeParameter parameter) { this.parameter = parameter; this.centerXProperty = new SimpleDoubleProperty(); this.centerYProperty = new SimpleDoubleProperty(); @@ -80,9 +80,11 @@ public void updateCenterCoords() { * @param newValue the new value. */ @FxThread - private void updateCenterCoords(@Nullable final ObservableValue observable, - @Nullable final Number oldValue, - @Nullable final Number newValue) { + private void updateCenterCoords( + @Nullable ObservableValue observable, + @Nullable Number oldValue, + @Nullable Number newValue + ) { var parameter = getParameter(); var nodeElement = parameter.getNodeElement(); diff --git a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java index 17c5987..04ca11b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java @@ -67,7 +67,7 @@ interface NodeElementFactory extends * @param shaderNodeName the shader node name. * @return true of the node name is user's shader node. */ - public static boolean isUserShaderNode(@NotNull final String shaderNodeName) {> + public static boolean isUserShaderNode(@NotNull String shaderNodeName) { return !SYSTEM_NAMESPACES.contains(shaderNodeName); } From d5c61e8ddf6bd9288b1151ec53a1792a82d56fe8 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Fri, 6 Apr 2018 10:06:03 +0300 Subject: [PATCH 23/25] updated dependencies. --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 778a585..9b1da8b 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ javadoc { } dependencies { - compile 'com.spaceshift:jmonkeybuilder:1.7.3-3' + compile 'com.spaceshift:jmonkeybuilder:1.7.3-4' testCompile "org.junit.platform:junit-platform-commons:$junitPlatformVersion" testRuntime "org.junit.platform:junit-platform-engine:$junitPlatformVersion" From 7a13ad9486c34eb462245e59af00e1ae477a82cd Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Mon, 9 Apr 2018 09:11:19 +0300 Subject: [PATCH 24/25] refactoring. --- .../shader/nodes/ShaderNodesEditorPlugin.java | 25 ++-- .../ui/control/tree/action/AddSndAction.java | 26 ++-- .../action/AddSndInputParameterAction.java | 10 +- .../action/AddSndOutputParameterAction.java | 10 +- .../tree/action/AddSndParameterAction.java | 47 ++++---- .../tree/action/AddSndShaderSourceAction.java | 43 ++++--- .../control/tree/action/DeleteSndAction.java | 12 +- ...ion.java => DeleteSndParameterAction.java} | 14 +-- .../action/DeleteSndShaderSourceAction.java | 12 +- .../action/EditSndDocumentationAction.java | 16 ++- .../factory/ShaderNodesTreeNodeFactory.java | 2 +- .../node/definition/SndParameterTreeNode.java | 4 +- .../ui/dialog/EditSndDocumentationDialog.java | 12 +- .../nodes/ui/preview/SndFilePreview.java | 47 ++++---- .../ui/preview/SndFilePreviewFactory.java | 2 +- .../shader/nodes/util/J3snExporter.java | 60 ++++++---- .../shader/nodes/util/MaterialDefUtils.java | 2 +- .../shader/nodes/util/ShaderNodeUtils.java | 111 +++++++++--------- 18 files changed, 235 insertions(+), 220 deletions(-) rename src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/{DeleteSndarameterAction.java => DeleteSndParameterAction.java} (70%) diff --git a/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java b/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java index 8a23b19..717407b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java +++ b/src/main/java/com/ss/editor/shader/nodes/ShaderNodesEditorPlugin.java @@ -1,6 +1,5 @@ package com.ss.editor.shader.nodes; -import com.jme3.asset.AssetManager; import com.jme3.shader.glsl.AstGlsl150ShaderGenerator; import com.jme3.shader.glsl.AstShaderGenerator; import com.ss.editor.FileExtensions; @@ -45,37 +44,37 @@ public class ShaderNodesEditorPlugin extends EditorPlugin { @NotNull public static final String PROJECT_FILE_EXTENSION = "j3snm"; - public ShaderNodesEditorPlugin(@NotNull final PluginContainer pluginContainer) { + public ShaderNodesEditorPlugin(@NotNull PluginContainer pluginContainer) { super(pluginContainer); } @Override - public void onAfterCreateJmeContext(@NotNull final PluginSystem pluginSystem) { + public void onAfterCreateJmeContext(@NotNull PluginSystem pluginSystem) { super.onAfterCreateJmeContext(pluginSystem); System.setProperty(AstShaderGenerator.PROP_USE_CASE, "false"); - final AssetManager assetManager = EditorUtil.getAssetManager(); + var assetManager = EditorUtil.getAssetManager(); assetManager.setShaderGenerator(new AstGlsl150ShaderGenerator(assetManager)); } @FxThread @Override - public void onBeforeCreateJavaFxContext(@NotNull final PluginSystem pluginSystem) { + public void onBeforeCreateJavaFxContext(@NotNull PluginSystem pluginSystem) { super.onBeforeCreateJavaFxContext(pluginSystem); - final ResourceManager resourceManager = ResourceManager.getInstance(); + var resourceManager = ResourceManager.getInstance(); resourceManager.registerInterestedFileType(FileExtensions.JME_SHADER_NODE); resourceManager.registerInterestedFileType(FileExtensions.GLSL_LIB); } @Override @FromAnyThread - public void register(@NotNull final CssRegistry registry) { + public void register(@NotNull CssRegistry registry) { super.register(registry); registry.register("com/ss/editor/shader/nodes/style.css", getClassLoader()); } @Override @FromAnyThread - public void register(@NotNull final FileCreatorRegistry registry) { + public void register(@NotNull FileCreatorRegistry registry) { super.register(registry); registry.register(ShaderNodesProjectFileCreator.DESCRIPTION); registry.register(ShaderNodeDefinitionsFileCreator.DESCRIPTION); @@ -83,7 +82,7 @@ public void register(@NotNull final FileCreatorRegistry registry) { @Override @FromAnyThread - public void register(@NotNull final EditorRegistry registry) { + public void register(@NotNull EditorRegistry registry) { super.register(registry); registry.register(ShaderNodesFileEditor.DESCRIPTION); registry.register(ShaderNodeDefinitionFileEditor.DESCRIPTION); @@ -91,21 +90,21 @@ public void register(@NotNull final EditorRegistry registry) { @Override @FromAnyThread - public void register(@NotNull final TreeNodeFactoryRegistry registry) { + public void register(@NotNull TreeNodeFactoryRegistry registry) { super.register(registry); registry.register(ShaderNodesTreeNodeFactory.getInstance()); } @Override @FromAnyThread - public void register(@NotNull final PropertyBuilderRegistry registry) { + public void register(@NotNull PropertyBuilderRegistry registry) { super.register(registry); registry.register(ShaderNodesPropertyBuilder.getInstance()); } @Override @FromAnyThread - public void register(@NotNull final FileIconManager iconManager) { + public void register(@NotNull FileIconManager iconManager) { super.register(iconManager); iconManager.register((path, extension) -> { if (PROJECT_FILE_EXTENSION.equals(extension)) { @@ -118,7 +117,7 @@ public void register(@NotNull final FileIconManager iconManager) { @Override @FromAnyThread - public void register(@NotNull final FilePreviewFactoryRegistry registry) { + public void register(@NotNull FilePreviewFactoryRegistry registry) { super.register(registry); registry.register(SndFilePreviewFactory.getInstance()); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java index 063828b..04cfd1f 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndAction.java @@ -40,7 +40,7 @@ public class AddSndAction extends AbstractNodeAction { @NotNull private static final String PROP_TYPE = "type"; - public AddSndAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public AddSndAction(@NotNull NodeTree nodeTree, @NotNull TreeNode node) { super(nodeTree, node); } @@ -66,7 +66,7 @@ protected void process() { definitions.add(new PropertyDefinition(STRING_FROM_LIST, Messages.MODEL_PROPERTY_TYPE, PROP_TYPE, ShaderType.Vertex.name(), AVAILABLE_TYPES)); - final GenericFactoryDialog dialog = new GenericFactoryDialog(definitions, this::addDefinition, this::validate); + var dialog = new GenericFactoryDialog(definitions, this::addDefinition, this::validate); dialog.setTitle(getName()); dialog.show(); } @@ -77,12 +77,12 @@ protected void process() { * @param vars the vars of the definition. */ @FxThread - private boolean validate(@NotNull final VarTable vars) { + private boolean validate(@NotNull VarTable vars) { - final String name = vars.getString(PROP_NAME); + var name = vars.getString(PROP_NAME); - final TreeNode node = getNode(); - final SndList element = (SndList) node.getElement(); + var node = getNode(); + var element = (SndList) node.getElement(); return element.getDefinitions().stream() .noneMatch(definition -> definition.getName().equals(name)); @@ -94,22 +94,22 @@ private boolean validate(@NotNull final VarTable vars) { * @param vars the vars of the definition. */ @FxThread - private void addDefinition(@NotNull final VarTable vars) { + private void addDefinition(@NotNull VarTable vars) { - final String definitionName = vars.getString(PROP_NAME); - final ShaderType type = vars.getEnum(PROP_TYPE, ShaderType.class); + var definitionName = vars.getString(PROP_NAME); + var type = vars.getEnum(PROP_TYPE, ShaderType.class); - final TreeNode node = getNode(); - final SndList element = (SndList) node.getElement(); + var node = getNode(); + var element = (SndList) node.getElement(); - final ShaderNodeDefinition definition = new ShaderNodeDefinition(); + var definition = new ShaderNodeDefinition(); definition.setName(definitionName); definition.setType(type); definition.setDocumentation(""); definition.setInputs(new ArrayList<>()); definition.setOutputs(new ArrayList<>()); - final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer()); + var changeConsumer = notNull(getNodeTree().getChangeConsumer()); changeConsumer.execute(new AddSndOperation(element, definition)); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java index d468d6a..34ef3fe 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndInputParameterAction.java @@ -16,20 +16,22 @@ */ public class AddSndInputParameterAction extends AddSndParameterAction { - public AddSndInputParameterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public AddSndInputParameterAction( + @NotNull NodeTree nodeTree, + @NotNull TreeNode node + ) { super(nodeTree, node); } @Override @FxThread - protected @NotNull List getCurrentParameters(@NotNull final ShaderNodeDefinition definition) { + protected @NotNull List getCurrentParameters(@NotNull ShaderNodeDefinition definition) { return definition.getInputs(); } @Override @FxThread - protected @NotNull List getOppositeParameters(@NotNull final ShaderNodeDefinition definition) { + protected @NotNull List getOppositeParameters(@NotNull ShaderNodeDefinition definition) { return definition.getOutputs(); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java index adc1a7f..97d2c30 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndOutputParameterAction.java @@ -16,20 +16,22 @@ */ public class AddSndOutputParameterAction extends AddSndParameterAction { - public AddSndOutputParameterAction(@NotNull final NodeTree nodeTree, - @NotNull final TreeNode node) { + public AddSndOutputParameterAction( + @NotNull NodeTree nodeTree, + @NotNull TreeNode node + ) { super(nodeTree, node); } @Override @FxThread - protected @NotNull List getCurrentParameters(@NotNull final ShaderNodeDefinition definition) { + protected @NotNull List getCurrentParameters(@NotNull ShaderNodeDefinition definition) { return definition.getOutputs(); } @Override @FxThread - protected @NotNull List getOppositeParameters(@NotNull final ShaderNodeDefinition definition) { + protected @NotNull List getOppositeParameters(@NotNull ShaderNodeDefinition definition) { return definition.getInputs(); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java index 22cb6fb..55bf3b4 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndParameterAction.java @@ -27,7 +27,6 @@ import org.jetbrains.annotations.Nullable; import java.util.List; -import java.util.Optional; /** * The action to add new parameter. @@ -42,7 +41,7 @@ public abstract class AddSndParameterAction extends AbstractNodeAction nodeTree, @NotNull final TreeNode node) { + public AddSndParameterAction(@NotNull NodeTree nodeTree, @NotNull TreeNode node) { super(nodeTree, node); } @@ -66,7 +65,8 @@ public AddSndParameterAction(@NotNull final NodeTree nodeTree, @NotNull final */ @FxThread protected abstract @NotNull List getCurrentParameters( - @NotNull final ShaderNodeDefinition definition); + @NotNull ShaderNodeDefinition definition + ); /** * Get the list of opposite parameters. @@ -76,7 +76,8 @@ public AddSndParameterAction(@NotNull final NodeTree nodeTree, @NotNull final */ @FxThread protected abstract @NotNull List getOppositeParameters( - @NotNull final ShaderNodeDefinition definition); + @NotNull ShaderNodeDefinition definition + ); @Override @FxThread @@ -87,7 +88,7 @@ protected void process() { definitions.add(new PropertyDefinition(STRING, Messages.MODEL_PROPERTY_NAME, PROP_NAME, "newVar")); definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_TYPE, PROP_TYPE, GlslType.FLOAT)); - final GenericFactoryDialog dialog = new GenericFactoryDialog(definitions, this::addParameter, this::validate); + var dialog = new GenericFactoryDialog(definitions, this::addParameter, this::validate); dialog.setTitle(getName()); dialog.show(); } @@ -98,25 +99,25 @@ protected void process() { * @param vars the vars of the new parameter. */ @FxThread - private boolean validate(@NotNull final VarTable vars) { + private boolean validate(@NotNull VarTable vars) { - final TreeNode node = getNode(); - final SndParameters parameters = (SndParameters) node.getElement(); - final ShaderNodeDefinition definition = parameters.getDefinition(); + var node = getNode(); + var parameters = (SndParameters) node.getElement(); + var definition = parameters.getDefinition(); - final String name = vars.getString(PROP_NAME); - final boolean exists = getCurrentParameters(definition).stream() + var name = vars.getString(PROP_NAME); + var exists = getCurrentParameters(definition).stream() .anyMatch(variable -> variable.getName().equals(name)); if (exists) { return false; } - final GlslType GlslType = vars.getEnum(PROP_TYPE, GlslType.class); - final String rawType = GlslType.getRawType(); + var glslType = vars.getEnum(PROP_TYPE, GlslType.class); + var rawType = glslType.getRawType(); - final List oppositeParameters = getOppositeParameters(definition); - final Optional oppositeParameter = oppositeParameters.stream() + var oppositeParameters = getOppositeParameters(definition); + var oppositeParameter = oppositeParameters.stream() .filter(variable -> variable.getName().equals(name)) .findAny(); @@ -124,7 +125,7 @@ private boolean validate(@NotNull final VarTable vars) { return true; } - final ShaderNodeVariable variable = oppositeParameter.get(); + var variable = oppositeParameter.get(); return StringUtils.equals(rawType, variable.getType()); } @@ -134,17 +135,17 @@ private boolean validate(@NotNull final VarTable vars) { * @param vars the vars of the parameter. */ @FxThread - private void addParameter(@NotNull final VarTable vars) { + private void addParameter(@NotNull VarTable vars) { - final TreeNode node = getNode(); - final SndParameters parameters = (SndParameters) node.getElement(); + var node = getNode(); + var parameters = (SndParameters) node.getElement(); - final String name = vars.getString(PROP_NAME); - final GlslType GlslType = vars.getEnum(PROP_TYPE, GlslType.class); + var name = vars.getString(PROP_NAME); + var GlslType = vars.getEnum(PROP_TYPE, GlslType.class); - final ShaderNodeVariable variable = new ShaderNodeVariable(GlslType.getRawType(), name); + var variable = new ShaderNodeVariable(GlslType.getRawType(), name); - final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer()); + var changeConsumer = notNull(getNodeTree().getChangeConsumer()); changeConsumer.execute(new AddSndParameterOperation(parameters, variable)); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java index bce7498..8304d11 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/AddSndShaderSourceAction.java @@ -6,8 +6,6 @@ import static com.ss.editor.util.EditorUtil.toAssetPath; import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.renderer.Caps; -import com.jme3.shader.Shader; -import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.plugin.api.dialog.GenericFactoryDialog; @@ -42,7 +40,7 @@ public class AddSndShaderSourceAction extends AbstractNodeAction @NotNull private static final String PROP_SHADER_RESOURCE = "resource"; - public AddSndShaderSourceAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public AddSndShaderSourceAction(@NotNull NodeTree nodeTree, @NotNull TreeNode node) { super(nodeTree, node); } @@ -63,10 +61,10 @@ public AddSndShaderSourceAction(@NotNull final NodeTree nodeTree, @NotNull fi protected void process() { super.process(); - final TreeNode node = getNode(); - final SndShaderSources shaderSources = (SndShaderSources) node.getElement(); - final ShaderNodeDefinition definition = shaderSources.getDefinition(); - final Shader.ShaderType type = definition.getType(); + var node = getNode(); + var shaderSources = (SndShaderSources) node.getElement(); + var definition = shaderSources.getDefinition(); + var type = definition.getType(); final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(STRING_FROM_LIST, PluginMessages.SND_CREATOR_LANGUAGE, PROP_LANGUAGE, @@ -74,7 +72,7 @@ protected void process() { definitions.add(new PropertyDefinition(FILE_FROM_ASSET_FOLDER, PluginMessages.SND_CREATOR_SOURCE_FILE, PROP_SHADER_RESOURCE, null, type.getExtension())); - final GenericFactoryDialog dialog = new GenericFactoryDialog(definitions, this::addShaderSource, this::validate); + var dialog = new GenericFactoryDialog(definitions, this::addShaderSource, this::validate); dialog.setTitle(getName()); dialog.show(); } @@ -85,18 +83,18 @@ protected void process() { * @param vars the vars of the definition. */ @FxThread - private boolean validate(@NotNull final VarTable vars) { + private boolean validate(@NotNull VarTable vars) { if (!vars.has(PROP_SHADER_RESOURCE)) { return false; } - final TreeNode node = getNode(); - final SndShaderSources shaderSources = (SndShaderSources) node.getElement(); - final ShaderNodeDefinition definition = shaderSources.getDefinition(); + var node = getNode(); + var shaderSources = (SndShaderSources) node.getElement(); + var definition = shaderSources.getDefinition(); - final Path shaderFile = vars.get(PROP_SHADER_RESOURCE, Path.class); - final String shaderPath = toAssetPath(shaderFile); + var shaderFile = vars.get(PROP_SHADER_RESOURCE, Path.class); + var shaderPath = toAssetPath(shaderFile); return !definition.getShadersPath().contains(shaderPath); } @@ -107,18 +105,17 @@ private boolean validate(@NotNull final VarTable vars) { * @param vars the vars of the source. */ @FxThread - private void addShaderSource(@NotNull final VarTable vars) { + private void addShaderSource(@NotNull VarTable vars) { - final String language = vars.getString(PROP_LANGUAGE); - final Path shaderFile = vars.get(PROP_SHADER_RESOURCE, Path.class); + var language = vars.getString(PROP_LANGUAGE); + var shaderFile = vars.get(PROP_SHADER_RESOURCE, Path.class); - final TreeNode node = getNode(); - final SndShaderSources shaderSources = (SndShaderSources) node.getElement(); - final ShaderNodeDefinition definition = shaderSources.getDefinition(); - final SndShaderSource shaderSource = - new SndShaderSource(definition, language, toAssetPath(shaderFile)); + var node = getNode(); + var shaderSources = (SndShaderSources) node.getElement(); + var definition = shaderSources.getDefinition(); + var shaderSource = new SndShaderSource(definition, language, toAssetPath(shaderFile)); - final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer()); + var changeConsumer = notNull(getNodeTree().getChangeConsumer()); changeConsumer.execute(new AddSndShaderSourceOperation(shaderSources, shaderSource)); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java index a12a967..91c29ea 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndAction.java @@ -22,7 +22,7 @@ */ public class DeleteSndAction extends AbstractNodeAction { - public DeleteSndAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public DeleteSndAction(@NotNull NodeTree nodeTree, @NotNull TreeNode node) { super(nodeTree, node); } @@ -43,13 +43,13 @@ public DeleteSndAction(@NotNull final NodeTree nodeTree, @NotNull final TreeN protected void process() { super.process(); - final TreeNode node = getNode(); - final TreeNode parent = notNull(node.getParent()); + var node = getNode(); + var parent = notNull(node.getParent()); - final ShaderNodeDefinition definition = (ShaderNodeDefinition) node.getElement(); - final SndList definitionList = (SndList) parent.getElement(); + var definition = (ShaderNodeDefinition) node.getElement(); + var definitionList = (SndList) parent.getElement(); - final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer()); + var changeConsumer = notNull(getNodeTree().getChangeConsumer()); changeConsumer.execute(new DeleteSndOperation(definitionList, definition)); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndParameterAction.java similarity index 70% rename from src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java rename to src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndParameterAction.java index 5fba766..8927281 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndarameterAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndParameterAction.java @@ -20,9 +20,9 @@ * * @author JavaSaBr */ -public class DeleteSndarameterAction extends AbstractNodeAction { +public class DeleteSndParameterAction extends AbstractNodeAction { - public DeleteSndarameterAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public DeleteSndParameterAction(@NotNull NodeTree nodeTree, @NotNull TreeNode node) { super(nodeTree, node); } @@ -43,12 +43,12 @@ public DeleteSndarameterAction(@NotNull final NodeTree nodeTree, @NotNull fin protected void process() { super.process(); - final TreeNode node = getNode(); - final TreeNode parent = notNull(node.getParent()); - final ShaderNodeVariable variable = (ShaderNodeVariable) node.getElement(); - final SndParameters parameters = (SndParameters) parent.getElement(); + var node = getNode(); + var parent = notNull(node.getParent()); + var variable = (ShaderNodeVariable) node.getElement(); + var parameters = (SndParameters) parent.getElement(); - final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer()); + var changeConsumer = notNull(getNodeTree().getChangeConsumer()); changeConsumer.execute(new DeleteSndParameterOperation(parameters, variable)); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java index 52bccd4..0b3cf87 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/DeleteSndShaderSourceAction.java @@ -22,7 +22,7 @@ */ public class DeleteSndShaderSourceAction extends AbstractNodeAction { - public DeleteSndShaderSourceAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public DeleteSndShaderSourceAction(@NotNull NodeTree nodeTree, @NotNull TreeNode node) { super(nodeTree, node); } @@ -43,12 +43,12 @@ public DeleteSndShaderSourceAction(@NotNull final NodeTree nodeTree, @NotNull protected void process() { super.process(); - final TreeNode node = getNode(); - final TreeNode parent = notNull(node.getParent()); - final SndShaderSource shaderSource = (SndShaderSource) node.getElement(); - final SndShaderSources shaderSources = (SndShaderSources) parent.getElement(); + var node = getNode(); + var parent = notNull(node.getParent()); + var shaderSource = (SndShaderSource) node.getElement(); + var shaderSources = (SndShaderSources) parent.getElement(); - final ChangeConsumer changeConsumer = notNull(getNodeTree().getChangeConsumer()); + var changeConsumer = notNull(getNodeTree().getChangeConsumer()); changeConsumer.execute(new DeleteSndShaderSourceOperation(shaderSources, shaderSource)); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java index 80c541c..45d4ad8 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/action/EditSndDocumentationAction.java @@ -1,11 +1,9 @@ package com.ss.editor.shader.nodes.ui.control.tree.action; import static com.ss.rlib.util.ObjectUtils.notNull; -import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.PluginMessages; -import com.ss.editor.shader.nodes.model.shader.node.definition.SndDocumentation; import com.ss.editor.shader.nodes.ui.control.tree.node.definition.SndDocumentationTreeNode; import com.ss.editor.shader.nodes.ui.dialog.EditSndDocumentationDialog; import com.ss.editor.ui.Icons; @@ -23,7 +21,7 @@ */ public class EditSndDocumentationAction extends AbstractNodeAction { - public EditSndDocumentationAction(@NotNull final NodeTree nodeTree, @NotNull final TreeNode node) { + public EditSndDocumentationAction(@NotNull NodeTree nodeTree, @NotNull TreeNode node) { super(nodeTree, node); } @@ -44,14 +42,14 @@ public EditSndDocumentationAction(@NotNull final NodeTree nodeTree, @NotNull protected void process() { super.process(); - final SndDocumentationTreeNode node = (SndDocumentationTreeNode) getNode(); - final SndDocumentation documentation = node.getElement(); - final ShaderNodeDefinition definition = documentation.getDefinition(); + var node = (SndDocumentationTreeNode) getNode(); + var documentation = node.getElement(); + var definition = documentation.getDefinition(); - final NodeTree nodeTree = getNodeTree(); - final ChangeConsumer changeConsumer = notNull(nodeTree.getChangeConsumer()); + var nodeTree = getNodeTree(); + var changeConsumer = notNull(nodeTree.getChangeConsumer()); - final EditSndDocumentationDialog dialog = new EditSndDocumentationDialog(changeConsumer, definition); + var dialog = new EditSndDocumentationDialog(changeConsumer, definition); dialog.show(); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java index fb34725..3d2caa3 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/factory/ShaderNodesTreeNodeFactory.java @@ -30,7 +30,7 @@ public class ShaderNodesTreeNodeFactory implements TreeNodeFactory { @Override @FxThread - public > @Nullable V createFor(@Nullable final T element, final long objectId) { + public > @Nullable V createFor(@Nullable T element, long objectId) { if (element instanceof PreviewMaterialSettings) { return unsafeCast(new PreviewMaterialSettingsTreeNode((PreviewMaterialSettings) element, objectId)); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java index 8336e37..2e9df75 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/control/tree/node/definition/SndParameterTreeNode.java @@ -6,7 +6,7 @@ import com.ss.editor.annotation.FromAnyThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.model.shader.node.definition.SndParameters; -import com.ss.editor.shader.nodes.ui.control.tree.action.DeleteSndarameterAction; +import com.ss.editor.shader.nodes.ui.control.tree.action.DeleteSndParameterAction; import com.ss.editor.shader.nodes.ui.control.tree.operation.RenameSndParameterOperation; import com.ss.editor.shader.nodes.ui.PluginIcons; import com.ss.editor.ui.control.tree.NodeTree; @@ -33,7 +33,7 @@ public SndParameterTreeNode(@NotNull final ShaderNodeVariable element, final lon @FxThread public void fillContextMenu(@NotNull final NodeTree nodeTree, @NotNull final ObservableList items) { super.fillContextMenu(nodeTree, items); - items.add(new DeleteSndarameterAction(nodeTree, this)); + items.add(new DeleteSndParameterAction(nodeTree, this)); } @FxThread diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java index 66ad492..4976020 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/dialog/EditSndDocumentationDialog.java @@ -4,13 +4,13 @@ import static com.ss.rlib.util.ObjectUtils.notNull; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.Messages; -import com.ss.editor.annotation.FxThread; import com.ss.editor.annotation.FromAnyThread; +import com.ss.editor.annotation.FxThread; import com.ss.editor.model.undo.editor.ChangeConsumer; import com.ss.editor.shader.nodes.PluginMessages; -import com.ss.editor.shader.nodes.ui.control.tree.operation.ChangeSndDocumentationOperation; import com.ss.editor.shader.nodes.ui.PluginCssClasses; import com.ss.editor.shader.nodes.ui.component.SndDocumentationArea; +import com.ss.editor.shader.nodes.ui.control.tree.operation.ChangeSndDocumentationOperation; import com.ss.editor.ui.dialog.AbstractSimpleEditorDialog; import com.ss.rlib.ui.util.FXUtils; import javafx.scene.input.KeyCode; @@ -48,8 +48,10 @@ public class EditSndDocumentationDialog extends AbstractSimpleEditorDialog { @Nullable private SndDocumentationArea editorArea; - public EditSndDocumentationDialog(@NotNull final ChangeConsumer consumer, - @NotNull final ShaderNodeDefinition definition) { + public EditSndDocumentationDialog( + @NotNull ChangeConsumer consumer, + @NotNull ShaderNodeDefinition definition + ) { this.consumer = consumer; this.definition = definition; //TODO replace to using util method @@ -69,7 +71,7 @@ public EditSndDocumentationDialog(@NotNull final ChangeConsumer consumer, @Override @FxThread - protected void createContent(@NotNull final VBox root) { + protected void createContent(@NotNull VBox root) { super.createContent(root); editorArea = new SndDocumentationArea(); diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java index c1d1d97..66ab4e5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreview.java @@ -1,6 +1,5 @@ package com.ss.editor.shader.nodes.ui.preview; -import com.jme3.asset.AssetManager; import com.jme3.asset.ShaderNodeDefinitionKey; import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.FileExtensions; @@ -26,14 +25,14 @@ public class SndFilePreview extends AbstractFilePreview { @Override @FxThread protected @NotNull SndDocumentationArea createGraphicsNode() { - final SndDocumentationArea documentationArea = new SndDocumentationArea(); + var documentationArea = new SndDocumentationArea(); documentationArea.setEditable(false); return documentationArea; } @Override @FxThread - protected void initialize(@NotNull final SndDocumentationArea node, @NotNull final StackPane pane) { + protected void initialize(@NotNull SndDocumentationArea node, @NotNull StackPane pane) { super.initialize(node, pane); node.prefWidthProperty().bind(pane.widthProperty()); node.prefHeightProperty().bind(pane.heightProperty()); @@ -41,27 +40,27 @@ protected void initialize(@NotNull final SndDocumentationArea node, @NotNull fin @Override @FxThread - public void show(@NotNull final Path file) { + public void show(@NotNull Path file) { super.show(file); - final String assetPath = EditorUtil.toAssetPath(file); - final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(assetPath); + var assetPath = EditorUtil.toAssetPath(file); + var key = new ShaderNodeDefinitionKey(assetPath); key.setLoadDocumentation(true); - final AssetManager assetManager = EditorUtil.getAssetManager(); - final List definitionList = assetManager.loadAsset(key); + var assetManager = EditorUtil.getAssetManager(); + var definitionList = assetManager.loadAsset(key); show(definitionList); } @FxThread - private void show(@NotNull final List definitionList) { + private void show(@NotNull List definitionList) { - final SndDocumentationArea documentationArea = getGraphicsNode(); + var documentationArea = getGraphicsNode(); if (definitionList.size() == 1) { - String documentation = definitionList.get(0).getDocumentation(); + var documentation = definitionList.get(0).getDocumentation(); if(StringUtils.isEmpty(documentation)) { documentationArea.reloadContent(" "); return; @@ -75,12 +74,14 @@ private void show(@NotNull final List definitionList) { return; } - final StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); - for (final ShaderNodeDefinition definition : definitionList) { + for (var definition : definitionList) { - final String documentation = definition.getDocumentation(); - if (StringUtils.isEmpty(documentation)) continue; + var documentation = definition.getDocumentation(); + if (StringUtils.isEmpty(documentation)) { + continue; + } result.append("// ----- ") .append(definition.getName()) @@ -94,29 +95,29 @@ private void show(@NotNull final List definitionList) { @Override @FxThread - public void show(@NotNull final String resource) { + public void show(@NotNull String resource) { super.show(resource); - final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(resource); + var key = new ShaderNodeDefinitionKey(resource); key.setLoadDocumentation(true); - final AssetManager assetManager = EditorUtil.getAssetManager(); - final List definitionList = assetManager.loadAsset(key); + var assetManager = EditorUtil.getAssetManager(); + var definitionList = assetManager.loadAsset(key); show(definitionList); } @Override @FxThread - public boolean isSupport(@NotNull final Path file) { - final String extension = FileUtils.getExtension(file); + public boolean isSupport(@NotNull Path file) { + var extension = FileUtils.getExtension(file); return FileExtensions.JME_SHADER_NODE.equals(extension); } @FxThread @Override - public boolean isSupport(@NotNull final String resource) { - final String extension = FileUtils.getExtension(resource); + public boolean isSupport(@NotNull String resource) { + var extension = FileUtils.getExtension(resource); return FileExtensions.JME_SHADER_NODE.equals(extension); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java index 05ccdce..43696c0 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/preview/SndFilePreviewFactory.java @@ -22,7 +22,7 @@ public class SndFilePreviewFactory implements FilePreviewFactory { @Override @FxThread - public void createFilePreviews(@NotNull final Array result) { + public void createFilePreviews(@NotNull Array result) { result.add(new SndFilePreview()); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/util/J3snExporter.java b/src/main/java/com/ss/editor/shader/nodes/util/J3snExporter.java index 8e27f47..1059970 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/J3snExporter.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/J3snExporter.java @@ -1,6 +1,5 @@ package com.ss.editor.shader.nodes.util; -import com.jme3.shader.Shader; import com.jme3.shader.ShaderNodeDefinition; import com.jme3.shader.ShaderNodeVariable; import com.ss.rlib.util.StringUtils; @@ -30,17 +29,17 @@ public class J3snExporter { * @param definitions the definitions. * @param out the output stream. */ - public void export(@NotNull final List definitions, @NotNull final OutputStream out) { + public void export(@NotNull List definitions, @NotNull OutputStream out) { - final StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); builder.append("ShaderNodeDefinitions {\n"); definitions.forEach(definition -> write(definition, builder)); builder.append("}"); - final String result = builder.toString(); + var result = builder.toString(); try { out.write(result.getBytes("UTF-8")); - } catch (final IOException e) { + } catch (IOException e) { throw new RuntimeException(e); } } @@ -51,22 +50,22 @@ public void export(@NotNull final List definitions, @NotNu * @param definition the definition. * @param builder the builder. */ - private void write(@NotNull final ShaderNodeDefinition definition, @NotNull final StringBuilder builder) { + private void write(@NotNull ShaderNodeDefinition definition, @NotNull StringBuilder builder) { indent(builder, 1); builder.append("ShaderNodeDefinition ") .append(definition.getName()) .append(" {\n"); - final Shader.ShaderType type = definition.getType(); + var type = definition.getType(); - final List shadersPath = definition.getShadersPath(); - final List shadersLanguage = definition.getShadersLanguage(); + var shadersPath = definition.getShadersPath(); + var shadersLanguage = definition.getShadersLanguage(); - final String documentation = definition.getDocumentation(); + var documentation = definition.getDocumentation(); - final List inputs = definition.getInputs(); - final List outputs = definition.getOutputs(); + var inputs = definition.getInputs(); + var outputs = definition.getOutputs(); indent(builder, 2); @@ -74,10 +73,10 @@ private void write(@NotNull final ShaderNodeDefinition definition, @NotNull fina .append(type.name()) .append("\n\n"); - for (int i = 0; i < shadersPath.size(); i++) { + for (var i = 0; i < shadersPath.size(); i++) { - final String path = shadersPath.get(i); - final String language = shadersLanguage.get(i); + var path = shadersPath.get(i); + var language = shadersLanguage.get(i); indent(builder, 2); @@ -119,16 +118,19 @@ private void write(@NotNull final ShaderNodeDefinition definition, @NotNull fina * @param builder the builder. * @param name the name of parameters node. */ - private void write(@NotNull final List variables, @NotNull final StringBuilder builder, - @NotNull final String name) { + private void write( + @NotNull List variables, + @NotNull StringBuilder builder, + @NotNull String name + ) { indent(builder, 2); builder.append(name).append(" {\n"); - for (final ShaderNodeVariable variable : variables) { + for (var variable : variables) { indent(builder, 3); - final String defaultValue = variable.getDefaultValue(); + var defaultValue = variable.getDefaultValue(); builder.append(variable.getType()) .append(' ') @@ -152,13 +154,16 @@ private void write(@NotNull final List variables, @NotNull f * @param builder the builder. * @param name the name of node. */ - private void writeStrings(@NotNull final List values, @NotNull final StringBuilder builder, - @NotNull final String name) { + private void writeStrings( + @NotNull List values, + @NotNull StringBuilder builder, + @NotNull String name + ) { indent(builder, 2); builder.append(name).append(" {\n"); - for (final String value : values) { + for (var value : values) { indent(builder, 3); builder.append(value).append('\n'); } @@ -173,14 +178,17 @@ private void writeStrings(@NotNull final List values, @NotNull final Str * @param builder the builder. * @param level the level. */ - private void indent(@NotNull final StringBuilder builder, final int level) { - if (level < 1) return; + private void indent(@NotNull StringBuilder builder, int level) { - int count = level * 4; + if (level < 1) { + return; + } + + var count = level * 4; builder.ensureCapacity(builder.length() + count); - for (int i = 0; i < count; i++) { + for (var i = 0; i < count; i++) { builder.append(' '); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/util/MaterialDefUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/MaterialDefUtils.java index 5d6cbf4..83eecb7 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/MaterialDefUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/MaterialDefUtils.java @@ -32,7 +32,7 @@ public class MaterialDefUtils { * @return the mat params. */ @FromAnyThread - public static @NotNull Map getMatParams(@NotNull final MaterialDef def) { + public static @NotNull Map getMatParams(@NotNull MaterialDef def) { return notNull(getFieldValue(def, MAT_PARAMS_FIELD)); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java index 04ca11b..dad68ca 100644 --- a/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java +++ b/src/main/java/com/ss/editor/shader/nodes/util/ShaderNodeUtils.java @@ -28,10 +28,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.Set; import java.util.function.BiFunction; -import java.util.function.Supplier; -import java.util.stream.IntStream; /** * The utility class. @@ -79,8 +80,8 @@ public static boolean isUserShaderNode(@NotNull String shaderNodeName) { * @return the option of shader node element. */ public static @NotNull Optional> createNodeElement( - @NotNull final ShaderNodesContainer container, - @NotNull final ShaderNodeVariable var + @NotNull ShaderNodesContainer container, + @NotNull ShaderNodeVariable var ) { return NODE_ELEMENT_FACTORIES.getOptional(var.getNameSpace()) .map(factory -> factory.apply(container, var)); @@ -95,8 +96,8 @@ public static boolean isUserShaderNode(@NotNull String shaderNodeName) { */ @FromAnyThread public static @Nullable MatParam findMatParameterByName( - @NotNull final MaterialDef materialDef, - @NotNull final String name + @NotNull MaterialDef materialDef, + @NotNull String name ) { return materialDef.getMaterialParams().stream() .filter(matParam -> matParam.getName().equals(name)) @@ -112,8 +113,8 @@ public static boolean isUserShaderNode(@NotNull String shaderNodeName) { */ @FromAnyThread public static @Nullable UniformBinding findWorldBindingByName( - @NotNull final TechniqueDef techniqueDef, - @NotNull final String name + @NotNull TechniqueDef techniqueDef, + @NotNull String name ) { return techniqueDef.getWorldBindings().stream() .filter(binding -> binding.name().equals(name)) @@ -129,8 +130,8 @@ public static boolean isUserShaderNode(@NotNull String shaderNodeName) { */ @FromAnyThread public static @Nullable ShaderNodeVariable findAttributeByName( - @NotNull final TechniqueDef techniqueDef, - @NotNull final String name + @NotNull TechniqueDef techniqueDef, + @NotNull String name ) { return techniqueDef.getShaderGenerationInfo().getAttributes().stream() .filter(variable -> variable.getName().equals(name)) @@ -146,8 +147,8 @@ public static boolean isUserShaderNode(@NotNull String shaderNodeName) { */ @FromAnyThread public static @Nullable ShaderNode findByName( - @NotNull final TechniqueDef techniqueDef, - @NotNull final String name + @NotNull TechniqueDef techniqueDef, + @NotNull String name ) { return techniqueDef.getShaderNodes().stream() .filter(shaderNode -> shaderNode.getName().equals(name)) @@ -163,8 +164,8 @@ public static boolean isUserShaderNode(@NotNull String shaderNodeName) { */ @FromAnyThread public static boolean equalsByNameAndNameSpace( - @NotNull final ShaderNodeVariable first, - @NotNull final ShaderNodeVariable second + @NotNull ShaderNodeVariable first, + @NotNull ShaderNodeVariable second ) { return StringUtils.equals(first.getName(), second.getName()) && StringUtils.equals(first.getNameSpace(), second.getNameSpace()); @@ -179,8 +180,8 @@ public static boolean equalsByNameAndNameSpace( */ @FromAnyThread public static boolean equalsByName( - @NotNull final ShaderNodeVariable first, - @NotNull final ShaderNodeVariable second + @NotNull ShaderNodeVariable first, + @NotNull ShaderNodeVariable second ) { return StringUtils.equals(first.getName(), second.getName()); } @@ -194,8 +195,8 @@ public static boolean equalsByName( */ @FromAnyThread public static @Nullable VariableMapping findOutMappingByNNLeftVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable ) { return shaderNode.getOutputMapping().stream() .filter(mapping -> equalsByNameAndNameSpace(mapping.getLeftVariable(), variable)) @@ -211,8 +212,8 @@ public static boolean equalsByName( */ @FromAnyThread public static @Nullable VariableMapping findInMappingByNLeftVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByName(mapping.getLeftVariable(), variable)) @@ -229,8 +230,8 @@ public static boolean equalsByName( */ @FromAnyThread public static @Nullable VariableMapping findInMappingByNNRightVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByNameAndNameSpace(mapping.getRightVariable(), variable)) @@ -246,8 +247,8 @@ public static boolean equalsByName( */ @FromAnyThread public static @NotNull List findInMappingsByNNRightVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByNameAndNameSpace(mapping.getRightVariable(), variable)) @@ -264,9 +265,9 @@ public static boolean equalsByName( */ @FromAnyThread public static @NotNull List findInMappingsByNNRightVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable, - @NotNull final String nameSpace + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable, + @NotNull String nameSpace ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByName(mapping.getRightVariable(), variable)) @@ -283,8 +284,8 @@ public static boolean equalsByName( */ @FromAnyThread public static @Nullable VariableMapping findInMappingByNNLeftVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByNameAndNameSpace(mapping.getLeftVariable(), variable)) @@ -301,9 +302,9 @@ public static boolean equalsByName( */ @FromAnyThread public static @Nullable VariableMapping findInMappingByNNLeftVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable, - @NotNull final String nameSpace + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable, + @NotNull String nameSpace ) { return shaderNode.getInputMapping().stream() .filter(mapping -> equalsByName(mapping.getLeftVariable(), variable)) @@ -320,8 +321,8 @@ public static boolean equalsByName( */ @FromAnyThread public static boolean hasOutMappingByLeftVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable ) { return shaderNode.getOutputMapping() .stream().anyMatch(mapping -> equalsByNameAndNameSpace(mapping.getLeftVariable(), variable)); @@ -336,8 +337,8 @@ public static boolean hasOutMappingByLeftVar( */ @FromAnyThread public static boolean hasInMappingByRightVar( - @NotNull final ShaderNode shaderNode, - @NotNull final ShaderNodeVariable variable + @NotNull ShaderNode shaderNode, + @NotNull ShaderNodeVariable variable ) { return shaderNode.getInputMapping() .stream().anyMatch(mapping -> equalsByNameAndNameSpace(mapping.getRightVariable(), variable)); @@ -352,8 +353,8 @@ public static boolean hasInMappingByRightVar( */ @FromAnyThread public static @NotNull VariableMapping makeExpressionMapping( - @NotNull final InputShaderNodeParameter inputParameter, - @NotNull final String expression + @NotNull InputShaderNodeParameter inputParameter, + @NotNull String expression ) { var element = inputParameter.getNodeElement(); @@ -385,8 +386,8 @@ public static boolean hasInMappingByRightVar( */ @FromAnyThread public static @NotNull VariableMapping makeMapping( - @NotNull final InputShaderNodeParameter inputParameter, - @NotNull final OutputShaderNodeParameter outputParameter + @NotNull InputShaderNodeParameter inputParameter, + @NotNull OutputShaderNodeParameter outputParameter ) { final ShaderNodeElement inElement = inputParameter.getNodeElement(); @@ -517,9 +518,9 @@ public static boolean hasInMappingByRightVar( */ @FromAnyThread public static boolean containsByNN( - @NotNull final Collection variables, - @NotNull final String name, - @NotNull final String nameSpace + @NotNull Collection variables, + @NotNull String name, + @NotNull String nameSpace ) { for (var variable : variables) { @@ -544,7 +545,7 @@ public static boolean containsByNN( * @return true if these types are accessible. */ @FromAnyThread - public static boolean isAccessibleType(@NotNull final String inType, @NotNull final String outType) { + public static boolean isAccessibleType(@NotNull String inType, @NotNull String outType) { if (!inType.contains("|") && !outType.contains("|")) { return inType.equals(outType); @@ -571,7 +572,7 @@ public static boolean isAccessibleType(@NotNull final String inType, @NotNull fi * @return true of this variable is required. */ @FromAnyThread - public static boolean isRequired(@NotNull final ShaderNodeVariable variable) { + public static boolean isRequired(@NotNull ShaderNodeVariable variable) { var glslType = GlslType.ofRawType(variable.getType()); @@ -591,7 +592,7 @@ public static boolean isRequired(@NotNull final ShaderNodeVariable variable) { * @param parameter the parameter. * @return true if the parameter is input parameter. */ - public static boolean isInput(@NotNull final ShaderNodeParameter parameter) { + public static boolean isInput(@NotNull ShaderNodeParameter parameter) { return parameter instanceof InputShaderNodeParameter; } @@ -603,8 +604,10 @@ public static boolean isInput(@NotNull final ShaderNodeParameter parameter) { * @return the right swizzling or null. */ @FromAnyThread - public static @NotNull String calculateRightSwizzling(@NotNull final ShaderNodeVariable leftVar, - @NotNull final ShaderNodeVariable rightVar) { + public static @NotNull String calculateRightSwizzling( + @NotNull ShaderNodeVariable leftVar, + @NotNull ShaderNodeVariable rightVar + ) { var leftType = leftVar.getType(); var rightType = rightVar.getType(); @@ -654,8 +657,10 @@ public static boolean isInput(@NotNull final ShaderNodeParameter parameter) { * @return the left swizzling or null. */ @FromAnyThread - public static @NotNull String calculateLeftSwizzling(@NotNull final ShaderNodeVariable leftVar, - @NotNull final ShaderNodeVariable rightVar) { + public static @NotNull String calculateLeftSwizzling( + @NotNull ShaderNodeVariable leftVar, + @NotNull ShaderNodeVariable rightVar + ) { //FIXME if (true) { @@ -704,8 +709,8 @@ public static boolean isInput(@NotNull final ShaderNodeParameter parameter) { * @return true if we can use expression for the node variable. */ public static boolean canUseExpression( - @NotNull final ShaderNodeElement nodeElement, - @NotNull final ShaderNodeVariable variable + @NotNull ShaderNodeElement nodeElement, + @NotNull ShaderNodeVariable variable ) { if (!(nodeElement instanceof MainShaderNodeElement)) { From 6e147f986d722135e2bed907a41693e0de943544 Mon Sep 17 00:00:00 2001 From: JavaSaBr Date: Tue, 10 Apr 2018 17:54:05 +0300 Subject: [PATCH 25/25] refactoring. --- .../nodes/model/PreviewMaterialSettings.java | 2 +- .../model/shader/node/ShaderNodesProject.java | 23 ++-- .../node/definition/SndDocumentation.java | 8 +- .../node/definition/SndInputParameters.java | 2 +- .../model/shader/node/definition/SndList.java | 2 +- .../node/definition/SndOutputParameters.java | 2 +- .../shader/node/definition/SndParameters.java | 5 +- .../node/definition/SndShaderSource.java | 14 ++- .../node/definition/SndShaderSources.java | 55 ++++----- .../ShaderNodeDefinitionsFileCreator.java | 36 +++--- .../ShaderNodesProjectFileCreator.java | 17 +-- .../ShaderNodeDefinitionFileEditor.java | 111 ++++++++++-------- .../editor/ShaderNodesChangeConsumer.java | 52 ++++---- .../editor/ShaderNodesEditor3DPart.java | 8 +- .../editor/ShaderNodesFileEditor.java | 55 +++++---- .../editor/state/ShaderNodeState.java | 8 +- .../editor/state/ShaderNodeVariableState.java | 16 ++- .../editor/state/ShaderNodesEditorState.java | 24 ++-- .../editor/state/TechniqueDefState.java | 68 ++++++----- 19 files changed, 266 insertions(+), 242 deletions(-) diff --git a/src/main/java/com/ss/editor/shader/nodes/model/PreviewMaterialSettings.java b/src/main/java/com/ss/editor/shader/nodes/model/PreviewMaterialSettings.java index a3418ac..01b4b47 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/PreviewMaterialSettings.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/PreviewMaterialSettings.java @@ -11,7 +11,7 @@ */ public class PreviewMaterialSettings extends RootMaterialSettings { - public PreviewMaterialSettings(@NotNull final Material material) { + public PreviewMaterialSettings(@NotNull Material material) { super(material); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java index 066ddfd..6c23022 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/ShaderNodesProject.java @@ -53,7 +53,7 @@ public ShaderNodesProject() { * @param techniqueDefStates the states of technique definitions of this project. */ @FromAnyThread - public void updateTechniqueDefStates(@NotNull final List techniqueDefStates) { + public void updateTechniqueDefStates(@NotNull List techniqueDefStates) { this.techniqueDefStates = new ArrayList<>(techniqueDefStates); } @@ -73,7 +73,7 @@ public void updateTechniqueDefStates(@NotNull final List tech * @param matParams the settings list of preview material. */ @FromAnyThread - public void setMatParams(@NotNull final Collection matParams) { + public void setMatParams(@NotNull Collection matParams) { this.matParams = new ArrayList<>(matParams); } @@ -103,7 +103,7 @@ public void setMatParams(@NotNull final Collection matParams) { * @param materialDefContent the content of material definition. */ @FromAnyThread - public void setMaterialDefContent(@NotNull final String materialDefContent) { + public void setMaterialDefContent(@NotNull String materialDefContent) { this.materialDefContent = materialDefContent; } @@ -119,17 +119,17 @@ public ShaderNodesProject jmeClone() { @Override @JmeThread - public void cloneFields(@NotNull final Cloner cloner, @NotNull final Object original) { + public void cloneFields(@NotNull Cloner cloner, @NotNull Object original) { matParams = cloner.clone(matParams); } @Override @JmeThread - public void write(@NotNull final JmeExporter ex) throws IOException { + public void write(@NotNull JmeExporter ex) throws IOException { - final byte[] techStates = EditorUtil.serialize(techniqueDefStates); + var techStates = EditorUtil.serialize(techniqueDefStates); - final OutputCapsule out = ex.getCapsule(this); + var out = ex.getCapsule(this); out.writeSavableArrayList(matParams, "matParams", null); out.write(materialDefContent, "materialDefContent", null); out.write(techStates, "techniqueDefStates", null); @@ -137,18 +137,19 @@ public void write(@NotNull final JmeExporter ex) throws IOException { @Override @JmeThread - public void read(@NotNull final JmeImporter im) throws IOException { + public void read(@NotNull JmeImporter im) throws IOException { + + var in = im.getCapsule(this); - final InputCapsule in = im.getCapsule(this); matParams = unsafeCast(in.readSavableArrayList("matParams", new ArrayList<>())); materialDefContent = in.readString("materialDefContent", null); - final byte[] techStates = in.readByteArray("techniqueDefStates", null); + var techStates = in.readByteArray("techniqueDefStates", null); if (techStates != null) { try { techniqueDefStates = EditorUtil.deserialize(techStates); - } catch (final RuntimeException e) { + } catch (RuntimeException e) { // we can skip it } } diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndDocumentation.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndDocumentation.java index c429586..44a5e00 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndDocumentation.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndDocumentation.java @@ -17,7 +17,7 @@ public class SndDocumentation { @NotNull private final ShaderNodeDefinition definition; - public SndDocumentation(@NotNull final ShaderNodeDefinition definition) { + public SndDocumentation(@NotNull ShaderNodeDefinition definition) { this.definition = definition; } @@ -45,7 +45,7 @@ public SndDocumentation(@NotNull final ShaderNodeDefinition definition) { * * @param documentation the documentation of this definition. */ - public void setDocumentation(@NotNull final String documentation) { + public void setDocumentation(@NotNull String documentation) { this.definition.setDocumentation(documentation); } @@ -53,14 +53,14 @@ public void setDocumentation(@NotNull final String documentation) { public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - final SndDocumentation that = (SndDocumentation) o; + var that = (SndDocumentation) o; if (!definition.equals(that.definition)) return false; return getDocumentation().equals(that.getDocumentation()); } @Override public int hashCode() { - int result = definition.hashCode(); + var result = definition.hashCode(); result = 31 * result + getDocumentation().hashCode(); return result; } diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndInputParameters.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndInputParameters.java index b88cc03..a54a03e 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndInputParameters.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndInputParameters.java @@ -14,7 +14,7 @@ */ public class SndInputParameters extends SndParameters { - public SndInputParameters(@NotNull final ShaderNodeDefinition definition) { + public SndInputParameters(@NotNull ShaderNodeDefinition definition) { super(definition); } diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java index b79684d..7ec26af 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndList.java @@ -19,7 +19,7 @@ public class SndList { @NotNull private List definitions; - public SndList(@NotNull final List definitions) { + public SndList(@NotNull List definitions) { this.definitions = definitions; } diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndOutputParameters.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndOutputParameters.java index e13bd4f..fa37837 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndOutputParameters.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndOutputParameters.java @@ -14,7 +14,7 @@ */ public class SndOutputParameters extends SndParameters { - public SndOutputParameters(@NotNull final ShaderNodeDefinition definition) { + public SndOutputParameters(@NotNull ShaderNodeDefinition definition) { super(definition); } diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndParameters.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndParameters.java index 68a9129..79fa587 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndParameters.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndParameters.java @@ -4,6 +4,7 @@ import com.jme3.shader.ShaderNodeVariable; import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -20,7 +21,7 @@ public abstract class SndParameters { @NotNull private final ShaderNodeDefinition definition; - protected SndParameters(@NotNull final ShaderNodeDefinition definition) { + protected SndParameters(@NotNull ShaderNodeDefinition definition) { this.definition = definition; } @@ -43,7 +44,7 @@ protected SndParameters(@NotNull final ShaderNodeDefinition definition) { } @Override - public boolean equals(final Object o) { + public boolean equals(@Nullable Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final SndParameters that = (SndParameters) o; diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndShaderSource.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndShaderSource.java index 10c63f8..a1790a5 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndShaderSource.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndShaderSource.java @@ -3,6 +3,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The class to present shader sources of a shader node definition. @@ -29,8 +30,11 @@ public class SndShaderSource { @NotNull private final String shaderPath; - public SndShaderSource(@NotNull final ShaderNodeDefinition definition, @NotNull final String language, - @NotNull final String shaderPath) { + public SndShaderSource( + @NotNull ShaderNodeDefinition definition, + @NotNull String language, + @NotNull String shaderPath + ) { this.definition = definition; this.language = language; this.shaderPath = shaderPath; @@ -67,10 +71,10 @@ public SndShaderSource(@NotNull final ShaderNodeDefinition definition, @NotNull } @Override - public boolean equals(final Object o) { + public boolean equals(@Nullable Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - final SndShaderSource that = (SndShaderSource) o; + var that = (SndShaderSource) o; if (!definition.equals(that.definition)) return false; if (!language.equals(that.language)) return false; return shaderPath.equals(that.shaderPath); @@ -78,7 +82,7 @@ public boolean equals(final Object o) { @Override public int hashCode() { - int result = definition.hashCode(); + var result = definition.hashCode(); result = 31 * result + language.hashCode(); result = 31 * result + shaderPath.hashCode(); return result; diff --git a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndShaderSources.java b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndShaderSources.java index 8a37182..513020c 100644 --- a/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndShaderSources.java +++ b/src/main/java/com/ss/editor/shader/nodes/model/shader/node/definition/SndShaderSources.java @@ -3,6 +3,7 @@ import com.jme3.shader.ShaderNodeDefinition; import com.ss.editor.annotation.FromAnyThread; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.HashMap; @@ -22,7 +23,7 @@ public class SndShaderSources { @NotNull private final ShaderNodeDefinition definition; - public SndShaderSources(@NotNull final ShaderNodeDefinition definition) { + public SndShaderSources(@NotNull ShaderNodeDefinition definition) { this.definition = definition; } @@ -34,12 +35,12 @@ public SndShaderSources(@NotNull final ShaderNodeDefinition definition) { @FromAnyThread public @NotNull Map getShadeSourceMap() { - final List shadersPath = definition.getShadersPath(); - final List shadersLanguage = definition.getShadersLanguage(); + var shadersPath = definition.getShadersPath(); + var shadersLanguage = definition.getShadersLanguage(); - final Map result = new HashMap<>(); + var result = new HashMap(); - for (int i = 0; i < shadersPath.size(); i++) { + for (var i = 0; i < shadersPath.size(); i++) { result.put(shadersPath.get(i), shadersLanguage.get(i)); } @@ -54,12 +55,12 @@ public SndShaderSources(@NotNull final ShaderNodeDefinition definition) { @FromAnyThread public @NotNull List getShadeSources() { - final List shadersPath = definition.getShadersPath(); - final List shadersLanguage = definition.getShadersLanguage(); + var shadersPath = definition.getShadersPath(); + var shadersLanguage = definition.getShadersLanguage(); - final List result = new ArrayList<>(); + var result = new ArrayList(); - for (int i = 0; i < shadersPath.size(); i++) { + for (var i = 0; i < shadersPath.size(); i++) { result.add(new SndShaderSource(definition, shadersPath.get(i), shadersLanguage.get(i))); } @@ -72,10 +73,10 @@ public SndShaderSources(@NotNull final ShaderNodeDefinition definition) { * @param shaderSource the new shader source. */ @FromAnyThread - public void add(@NotNull final SndShaderSource shaderSource) { + public void add(@NotNull SndShaderSource shaderSource) { - final List shadersPath = definition.getShadersPath(); - final List shadersLanguage = definition.getShadersLanguage(); + var shadersPath = definition.getShadersPath(); + var shadersLanguage = definition.getShadersLanguage(); shadersPath.add(shaderSource.getShaderPath()); shadersLanguage.add(shaderSource.getLanguage()); @@ -88,10 +89,10 @@ public void add(@NotNull final SndShaderSource shaderSource) { * @param shaderSource the new shader source. */ @FromAnyThread - public void add(final int index, @NotNull final SndShaderSource shaderSource) { + public void add(int index, @NotNull SndShaderSource shaderSource) { - final List shadersPath = definition.getShadersPath(); - final List shadersLanguage = definition.getShadersLanguage(); + var shadersPath = definition.getShadersPath(); + var shadersLanguage = definition.getShadersLanguage(); shadersPath.add(index, shaderSource.getShaderPath()); shadersLanguage.add(index, shaderSource.getLanguage()); @@ -103,12 +104,12 @@ public void add(final int index, @NotNull final SndShaderSource shaderSource) { * @param shaderSource the shader source. */ @FromAnyThread - public void remove(@NotNull final SndShaderSource shaderSource) { + public void remove(@NotNull SndShaderSource shaderSource) { - final List shadersPath = definition.getShadersPath(); - final List shadersLanguage = definition.getShadersLanguage(); + var shadersPath = definition.getShadersPath(); + var shadersLanguage = definition.getShadersLanguage(); - final int index = indexOf(shaderSource); + var index = indexOf(shaderSource); if (index == -1) { throw new IllegalArgumentException("not found the shader source " + shaderSource); @@ -125,15 +126,15 @@ public void remove(@NotNull final SndShaderSource shaderSource) { * @return the position or -1. */ @FromAnyThread - public int indexOf(@NotNull final SndShaderSource shaderSource) { + public int indexOf(@NotNull SndShaderSource shaderSource) { - final List shadersPath = definition.getShadersPath(); - final List shadersLanguage = definition.getShadersLanguage(); + var shadersPath = definition.getShadersPath(); + var shadersLanguage = definition.getShadersLanguage(); - for (int i = 0; i < shadersPath.size(); i++) { + for (var i = 0; i < shadersPath.size(); i++) { - final String path = shadersPath.get(i); - final String language = shadersLanguage.get(i); + var path = shadersPath.get(i); + var language = shadersLanguage.get(i); if (path.equals(shaderSource.getShaderPath()) && language.equals(shaderSource.getLanguage())) { return i; @@ -154,10 +155,10 @@ public int indexOf(@NotNull final SndShaderSource shaderSource) { } @Override - public boolean equals(final Object o) { + public boolean equals(@Nullable Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - final SndShaderSources that = (SndShaderSources) o; + var that = (SndShaderSources) o; return definition.equals(that.definition); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java index 37f78bf..8ae61c6 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodeDefinitionsFileCreator.java @@ -82,15 +82,15 @@ public class ShaderNodeDefinitionsFileCreator extends GenericFileCreator { AVAILABLE_TYPES.add(ShaderType.Vertex.name()); AVAILABLE_TYPES.add(ShaderType.Fragment.name()); - final Renderer renderer = EditorUtil.getRenderer(); + var renderer = EditorUtil.getRenderer(); - final EnumSet caps = renderer.getCaps(); + var caps = renderer.getCaps(); caps.stream().filter(cap -> cap.name().startsWith("GLSL")) .map(Enum::name) .sorted(StringUtils::compareIgnoreCase) .forEach(AVAILABLE_GLSL::add); - final InputStream snResource = ShaderNodesProjectFileCreator.class + var snResource = ShaderNodesProjectFileCreator.class .getResourceAsStream("/com/ss/editor/shader/nodes/template/ShaderNodeTemplate.j3sn"); SN_TEMPLATE = FileUtils.read(snResource); @@ -100,7 +100,7 @@ public class ShaderNodeDefinitionsFileCreator extends GenericFileCreator { @FromAnyThread protected @NotNull Array getPropertyDefinitions() { - final Array result = ArrayFactory.newArray(PropertyDefinition.class); + Array result = ArrayFactory.newArray(PropertyDefinition.class); result.add(new PropertyDefinition(EditablePropertyType.STRING, PluginMessages.SND_CREATOR_DEFINITION_NAME, PROP_DEFINITION_NAME, "newShaderNode")); result.add(new PropertyDefinition(EditablePropertyType.STRING_FROM_LIST, @@ -128,33 +128,33 @@ public class ShaderNodeDefinitionsFileCreator extends GenericFileCreator { protected void processOk() { super.hide(); - final Path shaderNodeFile = notNull(getFileToCreate()); - final Path folder = shaderNodeFile.getParent(); + var shaderNodeFile = notNull(getFileToCreate()); + var folder = shaderNodeFile.getParent(); - final VarTable vars = getVars(); - final String definitionName = vars.getString(PROP_DEFINITION_NAME); - final Caps language = vars.getEnum(PROP_LANGUAGE, Caps.class); - final ShaderType type = vars.getEnum(PROP_TYPE, ShaderType.class); + var vars = getVars(); + var definitionName = vars.getString(PROP_DEFINITION_NAME); + var language = vars.getEnum(PROP_LANGUAGE, Caps.class); + var type = vars.getEnum(PROP_TYPE, ShaderType.class); - final Path shaderFile = folder.resolve(definitionName + "." + type.getExtension()); - final Path assetShaderFile = notNull(getAssetFile(shaderFile)); - final String assetShaderPath = toAssetPath(assetShaderFile); + var shaderFile = folder.resolve(definitionName + "." + type.getExtension()); + var assetShaderFile = notNull(getAssetFile(shaderFile)); + var assetShaderPath = toAssetPath(assetShaderFile); - String result = SN_TEMPLATE.replace("${name}", definitionName); + var result = SN_TEMPLATE.replace("${name}", definitionName); result = result.replace("${type}", type.name()); result = result.replace("${glsl}", language.name()); result = result.replace("${shader_path}", assetShaderPath); - try (final PrintWriter out = new PrintWriter(Files.newOutputStream(shaderNodeFile, WRITE, TRUNCATE_EXISTING, CREATE))) { + try (var out = new PrintWriter(Files.newOutputStream(shaderNodeFile, WRITE, TRUNCATE_EXISTING, CREATE))) { out.print(result); - } catch (final IOException e) { + } catch (IOException e) { EditorUtil.handleException(LOGGER, this, e); return; } - try (final PrintWriter out = new PrintWriter(Files.newOutputStream(shaderFile, WRITE, TRUNCATE_EXISTING, CREATE))) { + try (var out = new PrintWriter(Files.newOutputStream(shaderFile, WRITE, TRUNCATE_EXISTING, CREATE))) { out.print("void main() {\n\n}"); - } catch (final IOException e) { + } catch (IOException e) { EditorUtil.handleException(LOGGER, this, e); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodesProjectFileCreator.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodesProjectFileCreator.java index 3f720b0..8425967 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodesProjectFileCreator.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/creator/ShaderNodesProjectFileCreator.java @@ -52,7 +52,8 @@ public class ShaderNodesProjectFileCreator extends GenericFileCreator { private static final String MD_TEMPLATE; static { - final InputStream mdResource = ShaderNodesProjectFileCreator.class + + var mdResource = ShaderNodesProjectFileCreator.class .getResourceAsStream("/com/ss/editor/shader/nodes/template/MaterialDefinition.j3md"); MD_TEMPLATE = FileUtils.read(mdResource); @@ -62,7 +63,7 @@ public class ShaderNodesProjectFileCreator extends GenericFileCreator { @FromAnyThread protected @NotNull Array getPropertyDefinitions() { - final Array definitions = ArrayFactory.newArray(PropertyDefinition.class); + Array definitions = ArrayFactory.newArray(PropertyDefinition.class); definitions.add(new PropertyDefinition(ENUM, Messages.MODEL_PROPERTY_LIGHT_MODE, PROP_TECHNIQUE_LIGHT_MODE, TechniqueDef.LightMode.SinglePassAndImageBased)); @@ -83,18 +84,18 @@ public class ShaderNodesProjectFileCreator extends GenericFileCreator { @Override @BackgroundThread - protected void writeData(@NotNull final VarTable vars, @NotNull final Path resultFile) throws IOException { + protected void writeData(@NotNull VarTable vars, @NotNull Path resultFile) throws IOException { super.writeData(vars, resultFile); - final TechniqueDef.LightMode lightMode = vars.getEnum(PROP_TECHNIQUE_LIGHT_MODE, TechniqueDef.LightMode.class); - final String updated = MD_TEMPLATE.replace("%light_mode%", lightMode.name()); + var lightMode = vars.getEnum(PROP_TECHNIQUE_LIGHT_MODE, TechniqueDef.LightMode.class); + var updated = MD_TEMPLATE.replace("%light_mode%", lightMode.name()); - final ShaderNodesProject project = new ShaderNodesProject(); + var project = new ShaderNodesProject(); project.setMaterialDefContent(updated); - final BinaryExporter exporter = BinaryExporter.getInstance(); + var exporter = BinaryExporter.getInstance(); - try (final OutputStream out = Files.newOutputStream(resultFile)) { + try (var out = Files.newOutputStream(resultFile)) { exporter.save(project, out); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java index 0d5a863..4ec9c18 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodeDefinitionFileEditor.java @@ -122,7 +122,7 @@ public ShaderNodeDefinitionFileEditor() { @Override @FxThread - protected void createToolComponents(@NotNull final EditorToolComponent container, @NotNull final StackPane root) { + protected void createToolComponents(@NotNull EditorToolComponent container, @NotNull StackPane root) { super.createToolComponents(container, root); structureTree = new NodeTree<>(this::selectFromTree, this, SelectionMode.SINGLE); @@ -137,7 +137,7 @@ protected void createToolComponents(@NotNull final EditorToolComponent container @FxThread @Override - protected void calcVSplitSize(@NotNull final SplitPane splitPane) { + protected void calcVSplitSize(@NotNull SplitPane splitPane) { splitPane.setDividerPosition(0, 0.6); } @@ -146,7 +146,7 @@ protected void calcVSplitSize(@NotNull final SplitPane splitPane) { protected void createEditorAreaPane() { super.createEditorAreaPane(); - final StackPane editorAreaPane = getEditorAreaPane(); + var editorAreaPane = getEditorAreaPane(); codeArea = new GLSLCodeArea(); codeArea.loadContent(""); @@ -171,19 +171,20 @@ protected void createEditorAreaPane() { * @param objects the selected objects. */ @FxThread - private void selectFromTree(@Nullable final Array objects) { + private void selectFromTree(@Nullable Array objects) { setEditedShader(null); - final GLSLCodeArea codeArea = getCodeArea(); + var codeArea = getCodeArea(); codeArea.setEditable(false); - final Object object = objects.first(); + var object = objects == null? null : objects.first(); + Object parent = null; Object element; if (object instanceof TreeNode) { - final TreeNode treeNode = (TreeNode) object; - final TreeNode parentNode = treeNode.getParent(); + var treeNode = (TreeNode) object; + var parentNode = treeNode.getParent(); parent = parentNode == null ? null : parentNode.getElement(); element = treeNode.getElement(); } else { @@ -192,17 +193,17 @@ private void selectFromTree(@Nullable final Array objects) { if (element instanceof SndShaderSource) { - final SndShaderSource shaderSource = (SndShaderSource) element; - final String code = getGlslCode(shaderSource.getShaderPath()); + var shaderSource = (SndShaderSource) element; + var code = getGlslCode(shaderSource.getShaderPath()); - EXECUTOR_MANAGER.schedule(() -> { + /* EXECUTOR_MANAGER.schedule(() -> { try { //FIXME to delete GlslParser.newInstance().parseFileDeclaration(shaderSource.getShaderPath(), code); } catch (final Throwable e) { e.printStackTrace(); } - }, 1000); + }, 1000);*/ setEditedShader(shaderSource.getShaderPath()); setIgnoreCodeChanges(true); @@ -253,7 +254,7 @@ private void selectFromTree(@Nullable final Array objects) { * @param editedShader the current edited shader. */ @FxThread - private void setEditedShader(@Nullable final String editedShader) { + private void setEditedShader(@Nullable String editedShader) { this.editedShader = editedShader; } @@ -273,7 +274,7 @@ private boolean isIgnoreCodeChanges() { * @param ignoreCodeChanges true if need to ignore GLSL code changes. */ @FxThread - private void setIgnoreCodeChanges(final boolean ignoreCodeChanges) { + private void setIgnoreCodeChanges(boolean ignoreCodeChanges) { this.ignoreCodeChanges = ignoreCodeChanges; } @@ -283,25 +284,25 @@ private void setIgnoreCodeChanges(final boolean ignoreCodeChanges) { * @param glslCode the new GLSL code. */ @FxThread - private void changeGLSLCode(@NotNull final String glslCode) { + private void changeGLSLCode(@NotNull String glslCode) { if (isIgnoreCodeChanges()) { return; } - final String editedShader = getEditedShader(); + var editedShader = getEditedShader(); if (editedShader == null) { return; } - final ObjectDictionary glslOriginalContent = getGlslOriginalContent(); - final String originalCode = glslOriginalContent.get(editedShader); + var glslOriginalContent = getGlslOriginalContent(); + var originalCode = glslOriginalContent.get(editedShader); if (!glslCode.equals(originalCode)) { incrementChange(); } - final ObjectDictionary glslChangedContent = getGlslChangedContent(); + var glslChangedContent = getGlslChangedContent(); glslChangedContent.put(editedShader, glslCode); } @@ -312,19 +313,19 @@ private void changeGLSLCode(@NotNull final String glslCode) { * @return the GLSL code. */ @FxThread - private @NotNull String getGlslCode(@NotNull final String shaderPath) { + private @NotNull String getGlslCode(@NotNull String shaderPath) { - final ObjectDictionary glslChangedContent = getGlslChangedContent(); - final String glslCode = glslChangedContent.get(shaderPath); + var glslChangedContent = getGlslChangedContent(); + var glslCode = glslChangedContent.get(shaderPath); if (glslCode != null) { return glslCode; } - final ObjectDictionary glslOriginalContent = getGlslOriginalContent(); - final Path realFile = notNull(getRealFile(shaderPath)); + var glslOriginalContent = getGlslOriginalContent(); + var realFile = notNull(getRealFile(shaderPath)); - final String readGLSLCode = FileUtils.read(realFile); + var readGLSLCode = FileUtils.read(realFile); glslOriginalContent.put(shaderPath, readGLSLCode); @@ -340,19 +341,20 @@ private void changeGLSLCode(@NotNull final String glslCode) { @Override @FxThread - protected void doOpenFile(@NotNull final Path file) throws IOException { + protected void doOpenFile(@NotNull Path file) throws IOException { super.doOpenFile(file); - final Path assetFile = notNull(getAssetFile(file)); - final String assetPath = toAssetPath(assetFile); - final ShaderNodeDefinitionKey key = new ShaderNodeDefinitionKey(assetPath); + var assetFile = notNull(getAssetFile(file)); + var assetPath = toAssetPath(assetFile); + + var key = new ShaderNodeDefinitionKey(assetPath); key.setLoadDocumentation(true); - final AssetManager assetManager = EditorUtil.getAssetManager(); + var assetManager = EditorUtil.getAssetManager(); definitionList = assetManager.loadAsset(key); - final NodeTree structureTree = getStructureTree(); + var structureTree = getStructureTree(); structureTree.fill(new SndList(definitionList)); structureTree.expandToLevel(1); } @@ -369,31 +371,31 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { @Override @BackgroundThread - protected void doSave(@NotNull final Path toStore) throws IOException { + protected void doSave(@NotNull Path toStore) throws IOException { super.doSave(toStore); - final J3snExporter exporter = J3snExporter.getInstance(); + var exporter = J3snExporter.getInstance(); - try (OutputStream out = Files.newOutputStream(toStore)) { + try (var out = Files.newOutputStream(toStore)) { exporter.export(getDefinitionList(), out); } - final ObjectDictionary glslChangedContent = getGlslChangedContent(); - final ObjectDictionary glslOriginalContent = getGlslOriginalContent(); + var glslChangedContent = getGlslChangedContent(); + var glslOriginalContent = getGlslOriginalContent(); glslChangedContent.forEach((path, content) -> { - final String original = glslOriginalContent.get(path); + var original = glslOriginalContent.get(path); if (StringUtils.equals(content, original)) { return; } - final Path realFile = notNull(getRealFile(path)); + var realFile = notNull(getRealFile(path)); - try (PrintStream out = new PrintStream(Files.newOutputStream(realFile))) { + try (var out = new PrintStream(Files.newOutputStream(realFile))) { out.print(content); - } catch (final IOException e) { + } catch (IOException e) { throw new RuntimeException(e); } @@ -429,7 +431,7 @@ protected boolean needToolbar() { @Override @FxThread - protected void createToolbar(@NotNull final HBox container) { + protected void createToolbar(@NotNull HBox container) { super.createToolbar(container); FXUtils.addToPane(createSaveAction(), container); } @@ -448,10 +450,14 @@ protected void createToolbar(@NotNull final HBox container) { @Override @FxThread - public void notifyFxAddedChild(@NotNull final Object parent, @NotNull final Object added, final int index, - final boolean needSelect) { - - final NodeTree structureTree = getStructureTree(); + public void notifyFxAddedChild( + @NotNull Object parent, + @NotNull Object added, + int index, + boolean needSelect + ) { + + var structureTree = getStructureTree(); structureTree.notifyAdded(parent, added, index); if (needSelect) { @@ -461,23 +467,24 @@ public void notifyFxAddedChild(@NotNull final Object parent, @NotNull final Obje @Override @FxThread - public void notifyFxRemovedChild(@NotNull final Object parent, @NotNull final Object removed) { + public void notifyFxRemovedChild(@NotNull Object parent, @NotNull Object removed) { getStructureTree().notifyRemoved(parent, removed); } @Override @FxThread - public void notifyFxChangeProperty(@Nullable final Object parent, @NotNull final Object object, - @NotNull final String propertyName) { + public void notifyFxChangeProperty( + @Nullable Object parent, + @NotNull Object object, + @NotNull String propertyName + ) { super.notifyFxChangeProperty(parent, object, propertyName); - final NodeTree structureTree = getStructureTree(); + var structureTree = getStructureTree(); structureTree.notifyChanged(parent, object); - final PropertyEditor propertyEditor = getPropertyEditor(); - if (object instanceof EditableProperty) { - propertyEditor.refresh(); + getPropertyEditor().refresh(); } } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java index a1f81b6..046091b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesChangeConsumer.java @@ -43,7 +43,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param mapping the variable mapping. */ @FxThread - void notifyAddedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping); + void notifyAddedMapping(@NotNull ShaderNode shaderNode, @NotNull VariableMapping mapping); /** * Notify about removed the variable mapping. @@ -52,7 +52,7 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { * @param mapping the variable mapping. */ @FxThread - void notifyRemovedMapping(@NotNull final ShaderNode shaderNode, @NotNull final VariableMapping mapping); + void notifyRemovedMapping(@NotNull ShaderNode shaderNode, @NotNull VariableMapping mapping); /** * Notify about replaced the variable mapping. @@ -63,9 +63,9 @@ public interface ShaderNodesChangeConsumer extends ChangeConsumer { */ @FxThread void notifyReplacedMapping( - @NotNull final ShaderNode shaderNode, - @NotNull final VariableMapping oldMapping, - @NotNull final VariableMapping newMapping + @NotNull ShaderNode shaderNode, + @NotNull VariableMapping oldMapping, + @NotNull VariableMapping newMapping ); /** @@ -75,7 +75,7 @@ void notifyReplacedMapping( * @param location the location. */ @FxThread - void notifyAddedMatParameter(@NotNull final MatParam matParam, @NotNull Vector2f location); + void notifyAddedMatParameter(@NotNull MatParam matParam, @NotNull Vector2f location); /** * Notify about removed the material parameter. @@ -83,7 +83,7 @@ void notifyReplacedMapping( * @param matParam the material parameter. */ @FxThread - void notifyRemovedMatParameter(@NotNull final MatParam matParam); + void notifyRemovedMatParameter(@NotNull MatParam matParam); /** * Notify about added the attribute. @@ -92,7 +92,7 @@ void notifyReplacedMapping( * @param location the location. */ @FxThread - void notifyAddedAttribute(@NotNull final ShaderNodeVariable variable, @NotNull Vector2f location); + void notifyAddedAttribute(@NotNull ShaderNodeVariable variable, @NotNull Vector2f location); /** * Notify about removed the attribute. @@ -100,7 +100,7 @@ void notifyReplacedMapping( * @param variable the variable of the attribute. */ @FxThread - void notifyRemovedAttribute(@NotNull final ShaderNodeVariable variable); + void notifyRemovedAttribute(@NotNull ShaderNodeVariable variable); /** * Notify about added the world parameter. @@ -109,7 +109,7 @@ void notifyReplacedMapping( * @param location the location. */ @FxThread - void notifyAddedWorldParameter(@NotNull final UniformBinding binding, @NotNull Vector2f location); + void notifyAddedWorldParameter(@NotNull UniformBinding binding, @NotNull Vector2f location); /** * Notify about removed the world parameter. @@ -117,7 +117,7 @@ void notifyReplacedMapping( * @param binding the binding. */ @FxThread - void notifyRemovedWorldParameter(@NotNull final UniformBinding binding); + void notifyRemovedWorldParameter(@NotNull UniformBinding binding); /** * Notify about added the shader nodes. @@ -126,7 +126,7 @@ void notifyReplacedMapping( * @param location the location. */ @FxThread - void notifyAddedShaderNode(@NotNull final ShaderNode shaderNode, @NotNull Vector2f location); + void notifyAddedShaderNode(@NotNull ShaderNode shaderNode, @NotNull Vector2f location); /** * Notify about removed the shader nodes. @@ -134,7 +134,7 @@ void notifyReplacedMapping( * @param shaderNode the shader nodes. */ @FxThread - void notifyRemovedRemovedShaderNode(@NotNull final ShaderNode shaderNode); + void notifyRemovedRemovedShaderNode(@NotNull ShaderNode shaderNode); /** * Notify about changed state of the shader nodes variable. @@ -145,9 +145,9 @@ void notifyReplacedMapping( */ @FxThread void notifyChangeState( - @NotNull final ShaderNodeVariable variable, - @NotNull final Vector2f location, - final double width + @NotNull ShaderNodeVariable variable, + @NotNull Vector2f location, + double width ); /** @@ -158,7 +158,7 @@ void notifyChangeState( * @param width the width. */ @FxThread - void notifyChangeState(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location, final double width); + void notifyChangeState(@NotNull ShaderNode shaderNode, @NotNull Vector2f location, double width); /** * Notify about changed state of the global nodes. @@ -168,7 +168,7 @@ void notifyChangeState( * @param width the width. */ @FxThread - void notifyChangeGlobalNodeState(final boolean input, @NotNull final Vector2f location, final double width); + void notifyChangeGlobalNodeState(boolean input, @NotNull Vector2f location, double width); /** * Get saved location of the shader nodes. @@ -177,7 +177,7 @@ void notifyChangeState( * @return the location or null. */ @FxThread - @Nullable Vector2f getLocation(@NotNull final ShaderNode shaderNode); + @Nullable Vector2f getLocation(@NotNull ShaderNode shaderNode); /** * Get saved location of the shader nodes variable. @@ -186,7 +186,7 @@ void notifyChangeState( * @return the location or null. */ @FxThread - @Nullable Vector2f getLocation(@NotNull final ShaderNodeVariable variable); + @Nullable Vector2f getLocation(@NotNull ShaderNodeVariable variable); /** * Get saved location of the global nodes. @@ -195,7 +195,7 @@ void notifyChangeState( * @return the location or null. */ @FxThread - @Nullable Vector2f getGlobalNodeLocation(final boolean input); + @Nullable Vector2f getGlobalNodeLocation(boolean input); /** * Get saved width of the shader nodes. @@ -204,7 +204,7 @@ void notifyChangeState( * @return the width or 0. */ @FxThread - double getWidth(@NotNull final ShaderNode shaderNode); + double getWidth(@NotNull ShaderNode shaderNode); /** * Get saved width of the shader nodes variable. @@ -213,7 +213,7 @@ void notifyChangeState( * @return the width or null. */ @FxThread - double getWidth(@NotNull final ShaderNodeVariable variable); + double getWidth(@NotNull ShaderNodeVariable variable); /** * Get saved width of the global nodes. @@ -222,7 +222,7 @@ void notifyChangeState( * @return the width or null. */ @FxThread - double getGlobalNodeWidth(final boolean input); + double getGlobalNodeWidth(boolean input); /** * Notify about added the technique definition. @@ -230,7 +230,7 @@ void notifyChangeState( * @param techniqueDef the technique definition. */ @FxThread - void notifyAddedTechnique(@NotNull final TechniqueDef techniqueDef); + void notifyAddedTechnique(@NotNull TechniqueDef techniqueDef); /** * Notify about removed the technique definition. @@ -238,5 +238,5 @@ void notifyChangeState( * @param techniqueDef the technique definition. */ @FxThread - void notifyRemovedTechnique(@NotNull final TechniqueDef techniqueDef); + void notifyRemovedTechnique(@NotNull TechniqueDef techniqueDef); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java index 83e9444..d00749b 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesEditor3DPart.java @@ -14,7 +14,7 @@ */ public class ShaderNodesEditor3DPart extends BaseMaterialEditor3DPart { - public ShaderNodesEditor3DPart(@NotNull final ShaderNodesFileEditor fileEditor) { + public ShaderNodesEditor3DPart(@NotNull ShaderNodesFileEditor fileEditor) { super(fileEditor); } @@ -25,7 +25,7 @@ public ShaderNodesEditor3DPart(@NotNull final ShaderNodesFileEditor fileEditor) * @param name the name. */ @FromAnyThread - public void selectTechnique(@NotNull final Material material, @NotNull final String name) { + public void selectTechnique(@NotNull Material material, @NotNull String name) { EXECUTOR_MANAGER.addJmeTask(() -> selectTechniqueImpl(material, name)); } @@ -36,13 +36,13 @@ public void selectTechnique(@NotNull final Material material, @NotNull final Str * @param name the name. */ @JmeThread - private void selectTechniqueImpl(@NotNull final Material material, @NotNull final String name) { + private void selectTechniqueImpl(@NotNull Material material, @NotNull String name) { material.selectTechnique(name, EditorUtil.getRenderManager()); updateMaterialImpl(material); } @Override - protected void handleMaterialException(@NotNull final RuntimeException exception) { + protected void handleMaterialException(@NotNull RuntimeException exception) { LOGGER.warning(this, exception); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java index 93e189d..58f73d0 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/ShaderNodesFileEditor.java @@ -197,36 +197,35 @@ public class ShaderNodesFileEditor extends @Override @FxThread - protected void doOpenFile(@NotNull final Path file) throws IOException { + protected void doOpenFile(@NotNull Path file) throws IOException { super.doOpenFile(file); - final AssetManager assetManager = EditorUtil.getAssetManager(); - final BinaryImporter importer = BinaryImporter.getInstance(); + var assetManager = EditorUtil.getAssetManager(); + var importer = BinaryImporter.getInstance(); importer.setAssetManager(assetManager); - try (final InputStream in = Files.newInputStream(file)) { + try (var in = Files.newInputStream(file)) { setProject((ShaderNodesProject) importer.load(in)); } catch (final IOException e) { throw new RuntimeException(e); } - final ShaderNodesProject project = getProject(); - final String materialDefContent = notNull(project.getMaterialDefContent()); + var project = getProject(); + var materialDefContent = notNull(project.getMaterialDefContent()); - final ByteArrayInputStream materialDefStream = - new ByteArrayInputStream(materialDefContent.getBytes("UTF-8")); + var materialDefStream = new ByteArrayInputStream(materialDefContent.getBytes("UTF-8")); - final AssetKey tempKey = new AssetKey<>("tempMatDef"); - final StreamAssetInfo assetInfo = new StreamAssetInfo(assetManager, tempKey, materialDefStream); + var tempKey = new AssetKey("tempMatDef"); + var assetInfo = new StreamAssetInfo(assetManager, tempKey, materialDefStream); - final J3MLoader loader = new J3MLoader(); - final MaterialDef materialDef = (MaterialDef) loader.load(assetInfo); + var loader = new J3MLoader(); + var materialDef = (MaterialDef) loader.load(assetInfo); materialDef.getTechniqueDefsNames().forEach(techniqueDefName -> { materialDef.getTechniqueDefs(techniqueDefName).forEach(techniqueDef -> { - final ShaderGenerationInfo info = techniqueDef.getShaderGenerationInfo(); - final List fragmentGlobals = info.getFragmentGlobals(); + var info = techniqueDef.getShaderGenerationInfo(); + var fragmentGlobals = info.getFragmentGlobals(); if (fragmentGlobals.isEmpty()) { fragmentGlobals.add(new ShaderNodeVariable("vec4", GlobalShaderNodeElement.NAMESPACE, "color", null)); @@ -240,7 +239,7 @@ protected void doOpenFile(@NotNull final Path file) throws IOException { setMaterialDef(materialDef); - final ShaderNodesEditor3DPart editor3DPart = getEditor3DPart(); + var editor3DPart = getEditor3DPart(); editor3DPart.updateMaterial(EditorUtil.getDefaultMaterial()); editor3DPart.changeMode(BaseMaterialEditor3DPart.ModelType.BOX); } @@ -252,14 +251,14 @@ protected void loadState() { EXECUTOR_MANAGER.addFxTask(this::buildMaterial); - final ShaderNodesEditorState editorState = getEditorState(); + var editorState = getEditorState(); if (editorState == null) { return; } editorState.cleanUp(getMaterialDef()); - final List defStates = editorState.getTechniqueDefStates(); + var defStates = editorState.getTechniqueDefStates(); if (defStates.isEmpty()) { defStates.addAll(getProject().getTechniqueDefStates()); @@ -268,24 +267,24 @@ protected void loadState() { @Override @BackgroundThread - protected void doSave(@NotNull final Path toStore) throws IOException { + protected void doSave(@NotNull Path toStore) throws IOException { super.doSave(toStore); - final BinaryExporter exporter = BinaryExporter.getInstance(); + var exporter = BinaryExporter.getInstance(); - final MaterialDef materialDef = getMaterialDef(); - final Material currentMaterial = getCurrentMaterial(); - final ByteArrayOutputStream bout = new ByteArrayOutputStream(); + var materialDef = getMaterialDef(); + var currentMaterial = getCurrentMaterial(); + var bout = new ByteArrayOutputStream(); - final ShaderNodesEditorState editorState = notNull(getEditorState()); - final List defStates = editorState.getTechniqueDefStates(); + var editorState = notNull(getEditorState()); + var defStates = editorState.getTechniqueDefStates(); - final J3mdExporter materialExporter = new J3mdExporter(); + var materialExporter = new J3mdExporter(); materialExporter.save(materialDef, bout); - final String materialDefContent = new String(bout.toByteArray(), "UTF-8"); + var materialDefContent = new String(bout.toByteArray(), "UTF-8"); - final ShaderNodesProject project = getProject(); + var project = getProject(); project.setMaterialDefContent(materialDefContent); project.updateTechniqueDefStates(defStates); @@ -293,7 +292,7 @@ protected void doSave(@NotNull final Path toStore) throws IOException { project.setMatParams(currentMaterial.getParams()); } - try (final OutputStream out = Files.newOutputStream(toStore)) { + try (var out = Files.newOutputStream(toStore)) { exporter.save(project, out); } } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java index e965f13..58150ed 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeState.java @@ -39,7 +39,7 @@ public ShaderNodeState() { this.location = Vector2f.ZERO; } - public ShaderNodeState(@NotNull final String name, @NotNull final Vector2f location, final int width) { + public ShaderNodeState(@NotNull String name, @NotNull Vector2f location, int width) { this.name = name; this.location = location; this.width = width; @@ -61,7 +61,7 @@ public ShaderNodeState(@NotNull final String name, @NotNull final Vector2f locat * @param name the name of a shader nodes. */ @FxThread - public void setName(@NotNull final String name) { + public void setName(@NotNull String name) { this.name = name; } @@ -81,7 +81,7 @@ public void setName(@NotNull final String name) { * @param location the location of a shader nodes. */ @FxThread - public void setLocation(@NotNull final Vector2f location) { + public void setLocation(@NotNull Vector2f location) { this.location = location; } @@ -101,7 +101,7 @@ public int getWidth() { * @param width the width of a shader nodes. */ @FxThread - public void setWidth(final int width) { + public void setWidth(int width) { this.width = width; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java index 06d1894..9964c51 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodeVariableState.java @@ -46,8 +46,12 @@ public ShaderNodeVariableState() { this.location = Vector2f.ZERO; } - public ShaderNodeVariableState(@NotNull final String name, @NotNull final String nameSpace, - @NotNull final Vector2f location, final int width) { + public ShaderNodeVariableState( + @NotNull String name, + @NotNull String nameSpace, + @NotNull Vector2f location, + int width + ) { this.name = name; this.nameSpace = nameSpace; this.location = location; @@ -71,7 +75,7 @@ public ShaderNodeVariableState(@NotNull final String name, @NotNull final String * @param name the name of a variable. */ @FxThread - public void setName(@NotNull final String name) { + public void setName(@NotNull String name) { this.name = name; } @@ -91,7 +95,7 @@ public void setName(@NotNull final String name) { * @param nameSpace the namespace of a variable. */ @FxThread - public void setNameSpace(@NotNull final String nameSpace) { + public void setNameSpace(@NotNull String nameSpace) { this.nameSpace = nameSpace; } @@ -111,7 +115,7 @@ public void setNameSpace(@NotNull final String nameSpace) { * @param location the location of a variable. */ @FxThread - public void setLocation(@NotNull final Vector2f location) { + public void setLocation(@NotNull Vector2f location) { this.location = location; } @@ -131,7 +135,7 @@ public int getWidth() { * @param width the width of a variable. */ @FxThread - public void setWidth(final int width) { + public void setWidth(int width) { this.width = width; } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java index 8be4555..3e4debc 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/ShaderNodesEditorState.java @@ -49,7 +49,7 @@ public ShaderNodesEditorState() { @Override @FxThread - public void setChangeHandler(@NotNull final Runnable changeHandler) { + public void setChangeHandler(@NotNull Runnable changeHandler) { super.setChangeHandler(changeHandler); techniqueDefStates.forEach(state -> state.setChangeHandler(changeHandler)); } @@ -61,9 +61,9 @@ public void setChangeHandler(@NotNull final Runnable changeHandler) { * @return the state. */ @FxThread - public @NotNull TechniqueDefState getState(@NotNull final String techniqueDefName) { + public @NotNull TechniqueDefState getState(@NotNull String techniqueDefName) { - final Optional result = techniqueDefStates.stream() + var result = techniqueDefStates.stream() .filter(state -> state.getName().equals(techniqueDefName)) .findAny(); @@ -71,7 +71,7 @@ public void setChangeHandler(@NotNull final Runnable changeHandler) { return result.get(); } - final TechniqueDefState newState = new TechniqueDefState(techniqueDefName); + var newState = new TechniqueDefState(techniqueDefName); newState.setChangeHandler(notNull(getChangeHandler())); techniqueDefStates.add(newState); @@ -86,14 +86,14 @@ public void setChangeHandler(@NotNull final Runnable changeHandler) { * @param materialDef the material definition. */ @FxThread - public void cleanUp(@NotNull final MaterialDef materialDef) { + public void cleanUp(@NotNull MaterialDef materialDef) { LOGGER.debug(this, editorState -> "The state before cleanup: " + editorState); - final Collection defsNames = materialDef.getTechniqueDefsNames(); + var defsNames = materialDef.getTechniqueDefsNames(); - for (Iterator iterator = techniqueDefStates.iterator(); iterator.hasNext(); ) { + for (var iterator = techniqueDefStates.iterator(); iterator.hasNext(); ) { - final TechniqueDefState state = iterator.next(); + var state = iterator.next(); if (!defsNames.contains(state.getName())) { iterator.remove(); @@ -101,8 +101,8 @@ public void cleanUp(@NotNull final MaterialDef materialDef) { continue; } - final List techniqueDefs = materialDef.getTechniqueDefs(state.getName()); - final TechniqueDef techniqueDef = techniqueDefs.get(0); + var techniqueDefs = materialDef.getTechniqueDefs(state.getName()); + var techniqueDef = techniqueDefs.get(0); state.cleanUp(materialDef, techniqueDef); } @@ -113,9 +113,9 @@ public void cleanUp(@NotNull final MaterialDef materialDef) { @Override public String toString() { - final StringBuilder builder = new StringBuilder("ShaderNodesEditorState:\n"); + var builder = new StringBuilder("ShaderNodesEditorState:\n"); - for (final TechniqueDefState defState : techniqueDefStates) { + for (var defState : techniqueDefStates) { builder.append("\t").append(defState).append('\n'); } diff --git a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java index 3c337f6..a2d9198 100644 --- a/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java +++ b/src/main/java/com/ss/editor/shader/nodes/ui/component/editor/state/TechniqueDefState.java @@ -78,7 +78,7 @@ public class TechniqueDefState extends AbstractEditorState { */ private int inputNodeWidth; - public TechniqueDefState(@NotNull final String name) { + public TechniqueDefState(@NotNull String name) { this.name = name; this.shaderNodeStates = new ArrayList<>(); this.shaderVariableStates = new ArrayList<>(); @@ -93,15 +93,15 @@ public TechniqueDefState(@NotNull final String name) { * @param techniqueDef the technique definition. */ @FxThread - public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final TechniqueDef techniqueDef) { + public void cleanUp(@NotNull MaterialDef materialDef, @NotNull TechniqueDef techniqueDef) { - for (final Iterator iterator = shaderVariableStates.iterator(); iterator.hasNext(); ) { + for (var iterator = shaderVariableStates.iterator(); iterator.hasNext(); ) { - final ShaderNodeVariableState state = iterator.next(); + var state = iterator.next(); if (MaterialShaderNodeElement.NAMESPACE.equals(state.getNameSpace())) { - final MatParam parameter = findMatParameterByName(materialDef, state.getName()); + var parameter = findMatParameterByName(materialDef, state.getName()); if (parameter == null) { iterator.remove(); @@ -110,7 +110,7 @@ public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final Techn } else if (WorldShaderNodeElement.NAMESPACE.equals(state.getNameSpace())) { - final UniformBinding binding = findWorldBindingByName(techniqueDef, state.getName()); + var binding = findWorldBindingByName(techniqueDef, state.getName()); if (binding == null) { iterator.remove(); @@ -119,7 +119,7 @@ public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final Techn } else if (AttributeShaderNodeElement.NAMESPACE.equals(state.getNameSpace())) { - final ShaderNodeVariable attribute = findAttributeByName(techniqueDef, state.getName()); + var attribute = findAttributeByName(techniqueDef, state.getName()); if (attribute == null) { iterator.remove(); @@ -128,10 +128,10 @@ public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final Techn } } - for (final Iterator iterator = shaderNodeStates.iterator(); iterator.hasNext(); ) { + for (var iterator = shaderNodeStates.iterator(); iterator.hasNext(); ) { - final ShaderNodeState state = iterator.next(); - final ShaderNode shaderNode = findByName(techniqueDef, state.getName()); + var state = iterator.next(); + var shaderNode = findByName(techniqueDef, state.getName()); if (shaderNode == null) { iterator.remove(); @@ -148,18 +148,21 @@ public void cleanUp(@NotNull final MaterialDef materialDef, @NotNull final Techn * @param width the width. */ @FxThread - public void notifyChange(@NotNull final ShaderNodeVariable variable, @NotNull final Vector2f location, - final double width) { + public void notifyChange( + @NotNull ShaderNodeVariable variable, + @NotNull Vector2f location, + double width + ) { LOGGER.debug(variable, location, (var, pos) -> "Changed shader node variable: " + var + " to location " + pos); - final Optional state = shaderVariableStates.stream() + var state = shaderVariableStates.stream() .filter(variableState -> variableState.getNameSpace().equals(variable.getNameSpace())) .filter(variableState -> variableState.getName().equals(variable.getName())) .findAny(); if (state.isPresent()) { - final ShaderNodeVariableState variableState = state.get(); + var variableState = state.get(); variableState.setLocation(location); variableState.setWidth((int) width); } else { @@ -180,17 +183,20 @@ public void notifyChange(@NotNull final ShaderNodeVariable variable, @NotNull fi * @param width the width. */ @FxThread - public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Vector2f location, - final double width) { + public void notifyChange( + @NotNull ShaderNode shaderNode, + @NotNull Vector2f location, + double width + ) { LOGGER.debug(shaderNode, location, (node, pos) -> "Changed shader node: " + node + " to location " + pos); - final Optional state = shaderNodeStates.stream() + var state = shaderNodeStates.stream() .filter(variableState -> variableState.getName().equals(shaderNode.getName())) .findAny(); if (state.isPresent()) { - final ShaderNodeState nodeState = state.get(); + var nodeState = state.get(); nodeState.setLocation(location); nodeState.setWidth((int) width); } else { @@ -209,7 +215,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * @return the state or null. */ @FxThread - public @Nullable ShaderNodeState getState(@NotNull final ShaderNode shaderNode) { + public @Nullable ShaderNodeState getState(@NotNull ShaderNode shaderNode) { return shaderNodeStates.stream() .filter(varState -> varState.getName().equals(shaderNode.getName())) .findAny().orElse(null); @@ -222,7 +228,7 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * @return the state or null. */ @FxThread - public @Nullable ShaderNodeVariableState getState(@Nullable final ShaderNodeVariable variable) { + public @Nullable ShaderNodeVariableState getState(@Nullable ShaderNodeVariable variable) { if (variable == null) return null; return shaderVariableStates.stream() .filter(variableState -> variableState.getNameSpace().equals(variable.getNameSpace())) @@ -266,8 +272,8 @@ public void notifyChange(@NotNull final ShaderNode shaderNode, @NotNull final Ve * @param inputNodeLocation the location of input nodes. */ @FxThread - public void setInputNodeLocation(@NotNull final Vector2f inputNodeLocation) { - final Vector2f prev = getInputNodeLocation(); + public void setInputNodeLocation(@NotNull Vector2f inputNodeLocation) { + var prev = getInputNodeLocation(); this.inputNodeLocation = inputNodeLocation; if (!prev.equals(inputNodeLocation)) notifyChange(); } @@ -278,8 +284,8 @@ public void setInputNodeLocation(@NotNull final Vector2f inputNodeLocation) { * @param outputNodeLocation the location of output nodes. */ @FxThread - public void setOutputNodeLocation(@NotNull final Vector2f outputNodeLocation) { - final Vector2f prev = getOutputNodeLocation(); + public void setOutputNodeLocation(@NotNull Vector2f outputNodeLocation) { + var prev = getOutputNodeLocation(); this.outputNodeLocation = outputNodeLocation; if (!prev.equals(outputNodeLocation)) notifyChange(); } @@ -310,8 +316,8 @@ public int getInputNodeWidth() { * @param outputNodeWidth the width of output nodes. */ @FxThread - public void setOutputNodeWidth(final int outputNodeWidth) { - final int prev = getOutputNodeWidth(); + public void setOutputNodeWidth(int outputNodeWidth) { + var prev = getOutputNodeWidth(); this.outputNodeWidth = outputNodeWidth; if (prev != outputNodeWidth) notifyChange(); } @@ -322,8 +328,8 @@ public void setOutputNodeWidth(final int outputNodeWidth) { * @param inputNodeWidth the width of input nodes. */ @FxThread - public void setInputNodeWidth(final int inputNodeWidth) { - final int prev = getInputNodeWidth(); + public void setInputNodeWidth(int inputNodeWidth) { + var prev = getInputNodeWidth(); this.inputNodeWidth = inputNodeWidth; if (prev != inputNodeWidth) notifyChange(); } @@ -331,13 +337,13 @@ public void setInputNodeWidth(final int inputNodeWidth) { @Override public String toString() { - final StringBuilder builder = new StringBuilder("TechniqueDefState"); + var builder = new StringBuilder("TechniqueDefState"); builder.append("(name:").append(name).append(")"); if (!shaderNodeStates.isEmpty()) { builder.append("\n\t\tShader Nodes:\n"); - for (final ShaderNodeState state : shaderNodeStates) { + for (var state : shaderNodeStates) { builder.append("\t\t\t").append(state).append("\n"); } @@ -347,7 +353,7 @@ public String toString() { if (!shaderVariableStates.isEmpty()) { builder.append("\n\t\tShader Variables:\n"); - for (final ShaderNodeVariableState state : shaderVariableStates) { + for (var state : shaderVariableStates) { builder.append("\t\t\t").append(state).append("\n"); }