From d529f07d905f4ae1189ae13d86fcd14285e97068 Mon Sep 17 00:00:00 2001 From: Dan Royer Date: Thu, 29 May 2025 15:45:44 -0700 Subject: [PATCH 1/4] add many icons --- .../marginallyclever/nodegraphcore/Node.java | 24 +++++++++++++++++- .../nodegraphcore/nodes/math/ATan2.java | 8 ++++++ .../nodegraphcore/nodes/math/Add.java | 8 ++++++ .../nodegraphcore/nodes/math/Divide.java | 8 ++++++ .../nodegraphcore/nodes/math/Equals.java | 8 ++++++ .../nodegraphcore/nodes/math/GreaterThan.java | 8 ++++++ .../nodegraphcore/nodes/math/LessThan.java | 8 ++++++ .../nodegraphcore/nodes/math/Multiply.java | 8 ++++++ .../nodegraphcore/nodes/math/Subtract.java | 8 ++++++ .../nodegraphcore/.placeholder | 0 .../nodegraphcore/icons8-question-mark-16.png | Bin 0 -> 213 bytes .../nodes/math/icons8-add-16.png | Bin 0 -> 176 bytes .../nodes/math/icons8-divide-16.png | Bin 0 -> 167 bytes .../nodes/math/icons8-equal-sign-16.png | Bin 0 -> 158 bytes .../nodes/math/icons8-less-or-equal-16.png | Bin 0 -> 250 bytes .../nodes/math/icons8-less-than-16.png | Bin 0 -> 225 bytes .../nodes/math/icons8-more-or-equal-16.png | Bin 0 -> 252 bytes .../nodes/math/icons8-more-than-16.png | Bin 0 -> 218 bytes .../nodes/math/icons8-multiply-16.png | Bin 0 -> 198 bytes .../nodes/math/icons8-subtract-16.png | Bin 0 -> 132 bytes .../nodegraphcore/nodes/math/tan_curve-16.ico | Bin 0 -> 135 bytes 21 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/.placeholder create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/icons8-question-mark-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-add-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-divide-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-equal-sign-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-less-or-equal-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-less-than-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-more-or-equal-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-more-than-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-multiply-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-subtract-16.png create mode 100644 src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/tan_curve-16.ico diff --git a/src/main/java/com/marginallyclever/nodegraphcore/Node.java b/src/main/java/com/marginallyclever/nodegraphcore/Node.java index 44b0506..f930045 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/Node.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/Node.java @@ -9,9 +9,11 @@ import org.json.JSONObject; import javax.annotation.Nonnull; +import javax.swing.*; import java.awt.*; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; @@ -167,13 +169,25 @@ public Port getPort(int index) throws IndexOutOfBoundsException { * @param name the name to match. * @return the {@link Port} found or null */ - public Port getPort(String name) { + public Port getPort(@Nonnull String name) { for(Port v : ports) { if(v.getName().equals(name)) return v; } return null; } + /** + * Get the {@link Port} with the given name and set its value. + * @param name the {@link Port} name to match. + * @param value the new value to set. + * @throws IllegalArgumentException when the {@link Port} is not found. + */ + public void setPort(@Nonnull String name, Object value) { + var port = getPort(name); + if(port == null) throw new IllegalArgumentException("Port "+name+" not found"); + port.setValue(value); + } + /** * @param name the {@link Port} name to match. * @return the index of the {@link Port} with the given name or -1 if not found. @@ -401,4 +415,12 @@ public int getComplete() { public void setComplete(int percent) { this.complete.set(percent); } + + /** + * Returns an icon for this node. + * @return an icon for this node or null if no icon is defined. + */ + abstract public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-question-mark-16.png"))); + } } diff --git a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/ATan2.java b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/ATan2.java index 6decc3f..2aa06d2 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/ATan2.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/ATan2.java @@ -4,6 +4,9 @@ import com.marginallyclever.nodegraphcore.port.Input; import com.marginallyclever.nodegraphcore.port.Output; +import javax.swing.*; +import java.util.Objects; + /** * C=atan2(y,x) * @author Dan Royer @@ -30,4 +33,9 @@ public void update() { double x = b.getValue().doubleValue(); c.setValue(Math.atan2(y,x)); } + + @Override + public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("tan-curve-16.png"))); + } } diff --git a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Add.java b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Add.java index 9bb48ba..28cebd7 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Add.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Add.java @@ -4,6 +4,9 @@ import com.marginallyclever.nodegraphcore.port.Input; import com.marginallyclever.nodegraphcore.port.Output; +import javax.swing.*; +import java.util.Objects; + /** * C=A+B * @author Dan Royer @@ -30,4 +33,9 @@ public void update() { double bv = b.getValue().doubleValue(); c.setValue(av + bv); } + + @Override + public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-add-16.png"))); + } } diff --git a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Divide.java b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Divide.java index e5359da..566c8a8 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Divide.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Divide.java @@ -4,6 +4,9 @@ import com.marginallyclever.nodegraphcore.port.Input; import com.marginallyclever.nodegraphcore.port.Output; +import javax.swing.*; +import java.util.Objects; + /** * C=A/B */ @@ -29,4 +32,9 @@ public void update() { if(bv==0) c.setValue(Float.NaN); else c.setValue(av / bv); } + + @Override + public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-divide-16.png"))); + } } diff --git a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Equals.java b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Equals.java index dcf20bd..8a3eabe 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Equals.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Equals.java @@ -4,6 +4,9 @@ import com.marginallyclever.nodegraphcore.port.Input; import com.marginallyclever.nodegraphcore.port.Output; +import javax.swing.*; +import java.util.Objects; + /** * C = (A==B) ? 1 : 0 * @author Dan Royer @@ -30,4 +33,9 @@ public void update() { double bv = b.getValue().doubleValue(); c.setValue((av == bv) ? 1 : 0); } + + @Override + public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-equal-sign-16.png"))); + } } diff --git a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/GreaterThan.java b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/GreaterThan.java index 9100d1e..cd9b985 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/GreaterThan.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/GreaterThan.java @@ -4,6 +4,9 @@ import com.marginallyclever.nodegraphcore.port.Input; import com.marginallyclever.nodegraphcore.port.Output; +import javax.swing.*; +import java.util.Objects; + /** * C = (A>B) ? 1 : 0 * @author Dan Royer @@ -30,4 +33,9 @@ public void update() { double bv = b.getValue().doubleValue(); c.setValue((av > bv) ? 1 : 0); } + + @Override + public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-more-than-16.png"))); + } } diff --git a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/LessThan.java b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/LessThan.java index fbc0056..e4c4bef 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/LessThan.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/LessThan.java @@ -4,6 +4,9 @@ import com.marginallyclever.nodegraphcore.port.Input; import com.marginallyclever.nodegraphcore.port.Output; +import javax.swing.*; +import java.util.Objects; + /** * C = (A<B) ? 1 : 0 * @author Dan Royer @@ -30,4 +33,9 @@ public void update() { double bv = b.getValue().doubleValue(); c.setValue((av < bv) ? 1 : 0); } + + @Override + public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-less-than-16.png"))); + } } diff --git a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Multiply.java b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Multiply.java index 8004114..f7ce525 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Multiply.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Multiply.java @@ -4,6 +4,9 @@ import com.marginallyclever.nodegraphcore.port.Input; import com.marginallyclever.nodegraphcore.port.Output; +import javax.swing.*; +import java.util.Objects; + /** * A*B {@link Node} */ @@ -28,4 +31,9 @@ public void update() { double bv = b.getValue().doubleValue(); c.setValue(av * bv); } + + @Override + public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-multiply-16.png"))); + } } diff --git a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Subtract.java b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Subtract.java index a9e9741..019bd26 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Subtract.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/nodes/math/Subtract.java @@ -4,6 +4,9 @@ import com.marginallyclever.nodegraphcore.port.Input; import com.marginallyclever.nodegraphcore.port.Output; +import javax.swing.*; +import java.util.Objects; + /** * A-B {@link Node} */ @@ -28,4 +31,9 @@ public void update() { double bv = b.getValue().doubleValue(); c.setValue(av - bv); } + + @Override + public Icon getIcon() { + return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-subtract-16.png"))); + } } diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/.placeholder b/src/main/resources/com/marginallyclever/nodegraphcore/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/icons8-question-mark-16.png b/src/main/resources/com/marginallyclever/nodegraphcore/icons8-question-mark-16.png new file mode 100644 index 0000000000000000000000000000000000000000..832d94aa1201363045b14d1335b7daa8b574486a GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP_W(8 z#WAE}&fW8hTugx?ZV%V{7<5D$%v5`MIJLvOfI024hzc8X8L*f8qD97P04>pZOCmXLU zV(`vL_^U4TKLM!0!R!E&md7?mk?O=5F3MI6KZQji6nv)4-^du?k=$Yy%E)m0xc)Ii S>pE?qZ492SelF{r5}E)8_%cNR literal 0 HcmV?d00001 diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-divide-16.png b/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-divide-16.png new file mode 100644 index 0000000000000000000000000000000000000000..79f7057d2aea55d7dd6190c308dccdeb136f75ce GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP%zTd z#WAE}PI7|88wcsGlT0~0JUsCWXH1Q8PBSnt@JU`E{vaVCK|n>Q`N|>&Z#K5J`9KB# zJCE2)NJ!{R;N8%`H7S?jXxswH8JxXdT|$?{y@V!-iSQ>eFmRky6g|*?OAlxXgQu&X J%Q~loCIHfVEV=*y literal 0 HcmV?d00001 diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-equal-sign-16.png b/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-equal-sign-16.png new file mode 100644 index 0000000000000000000000000000000000000000..163fcd9b63d624401aeec717bebf24260c43b414 GIT binary patch literal 158 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP%yyL z#WAE}&fAL{IU5WZTrRpVGiX*-wwNP%@S%v}vJGAWDy{N$l}GP>EEW#jP#%@FY+?aV zRjL%DWcKovX=+M5VJFUW{e0U|_~97u>F3rnCkx+tYhurtu>)iwgQu&X%Q~loCIHXL BGJgO7 literal 0 HcmV?d00001 diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-less-or-equal-16.png b/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-less-or-equal-16.png new file mode 100644 index 0000000000000000000000000000000000000000..f8dea5e302e22895def162d0798bf59aca368ce5 GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP;iZ> zi(^Q|oU4}%`5YZZS|93*XqhcIt`xFJpz{#l7a=X{fLA8d6ud-xSE!mfxU3J+nlOD& zl9JrKuE}$<-u+KkEB-lMfv#A2b7;&+OxAoQ?Kz!i(*%%%TWm{)z4>Vy>QS>U~TP8Ewzlj(KDo8ajrdT v+&RYlC4A)(3~owQgG7U zv&ZJ={5<>a3}3yE{AZaPhq%mb4E+w;zG14FZ@VhO=CI`f>uVXu4{%A_Fxe$aRlnvq zer)pg7snncu49bb(9?R9>x!;SQM8895vBVpCgyiv@znja^VH-kOr>lQPae&$WIX#$ W^X8N7_G^L8WAJqKb6Mw<&;$U3%vA#b literal 0 HcmV?d00001 diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-more-or-equal-16.png b/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-more-or-equal-16.png new file mode 100644 index 0000000000000000000000000000000000000000..0fe6f6337a41835a3b77359e9f5cb964251ef3f0 GIT binary patch literal 252 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP;i~6 zi(^Q|oU@lUay14@9Qzp0qn3BT@7+O_r97u(cQ6?4WL|vskr0pCWY5T{(h4_w-I%Su z@~Z!=nepfK%yYm0SU>;rDgVpHqYO*qS-9^^jxlikD(xt!JV)swulAOSzeA?Di@){| z+2sCuwzQ~0<)oI|DM801p0B7lDl@hGXp~V&Z`X4du_ZHe7CqwI`$SUy@{Iz~rg8C)W-$r3v!?ed5}LKdFB~*`5(wbT~q OE(T9mKbLh*2~7Zfzf-yZ literal 0 HcmV?d00001 diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-multiply-16.png b/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-multiply-16.png new file mode 100644 index 0000000000000000000000000000000000000000..a45b772928c313d5c71baeb29e9876a2f63ec2f2 GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP_V+& z#WAE}&fQ7gTnz?1F84jTF3#4hay)oG)n%{8(tw3izA&%*vi6ip%8Vr+tg8|jT~=D= zvhKRmz`5aoAg|#1$orFzFzn9X(_nVVZ-M5~2?ySG+>0`qdSUA=OY;Yv!L55b6Q;Cg tcKaHI&$;+jMY2)%^Te23jiWy#%vUbccX*q9S{>*H22WQ%mvv4FO#l~MNzecQ literal 0 HcmV?d00001 diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-subtract-16.png b/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/icons8-subtract-16.png new file mode 100644 index 0000000000000000000000000000000000000000..c8918b0507f6bfb5c803f742bd511d67cc196768 GIT binary patch literal 132 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP|(cN z#WAE}PI7_-YcqF&fq?;sP^V*7V1p_%^I?BBwzmH+kK}oHc*IVyML4jYG;2uG?`dje ZVfdOQrQDmjqY`KWgQu&X%Q~loCIHjSAD;jK literal 0 HcmV?d00001 diff --git a/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/tan_curve-16.ico b/src/main/resources/com/marginallyclever/nodegraphcore/nodes/math/tan_curve-16.ico new file mode 100644 index 0000000000000000000000000000000000000000..fda169dced39b33614cdec29f59755e1bed4536d GIT binary patch literal 135 zcmZQzU<5(|0R|vYU?>EVVnEy(;OEZECB+3~@_Kr>1OaJ~3IPr_ASwU(eIPn6mK&0z3!^>bP0l+XkKk|ZW( literal 0 HcmV?d00001 From 569e5236945f4863e833324990839501a4a7b868 Mon Sep 17 00:00:00 2001 From: Dan Royer Date: Wed, 16 Jul 2025 10:04:56 -0700 Subject: [PATCH 2/4] getIcon no longer abstract --- src/main/java/com/marginallyclever/nodegraphcore/Node.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/marginallyclever/nodegraphcore/Node.java b/src/main/java/com/marginallyclever/nodegraphcore/Node.java index f930045..a691e35 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/Node.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/Node.java @@ -420,7 +420,7 @@ public void setComplete(int percent) { * Returns an icon for this node. * @return an icon for this node or null if no icon is defined. */ - abstract public Icon getIcon() { + public Icon getIcon() { return new ImageIcon(Objects.requireNonNull(getClass().getResource("icons8-question-mark-16.png"))); } } From a5911aedcb15b10acdba5984d14b494363828301 Mon Sep 17 00:00:00 2001 From: Dan Royer Date: Wed, 16 Jul 2025 10:13:49 -0700 Subject: [PATCH 3/4] Update NodeCategory.java --- .../com/marginallyclever/nodegraphcore/NodeCategory.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/marginallyclever/nodegraphcore/NodeCategory.java b/src/main/java/com/marginallyclever/nodegraphcore/NodeCategory.java index 746f1f1..ec6bb73 100644 --- a/src/main/java/com/marginallyclever/nodegraphcore/NodeCategory.java +++ b/src/main/java/com/marginallyclever/nodegraphcore/NodeCategory.java @@ -4,6 +4,11 @@ import java.util.List; import java.util.function.Supplier; +/** + * A category of {@link Node} that can be used to organize nodes into a tree structure. + * Each category can have a parent and children, allowing for hierarchical organization. + * Categories can also provide a supplier to create instances of the node type they represent. + */ public class NodeCategory { private final String name; private final Supplier supplier; From 2c151fa82e924e7b2343a7818340e809e85e3d43 Mon Sep 17 00:00:00 2001 From: Dan Royer Date: Wed, 16 Jul 2025 10:14:02 -0700 Subject: [PATCH 4/4] 1.6.2 and bump dependencies --- pom.xml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 6748faf..2f09960 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.marginallyclever nodegraphcore - 1.6.1 + 1.6.2 NodeGraphCore Flow based programming in Java. @@ -57,7 +57,7 @@ org.json json - 20231013 + 20250517 @@ -74,24 +74,20 @@ test - org.slf4j slf4j-api - 2.0.16 + 2.0.17 + + + ch.qos.logback + logback-core + 1.5.18 - ch.qos.logback logback-classic - 1.5.16 - test - - - org.slf4j - slf4j-api - - + 1.5.18