Skip to content

Commit 29c896c

Browse files
committed
add graph.nodeHasInputConnections
1 parent 0617124 commit 29c896c

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.marginallyclever</groupId>
66
<artifactId>nodegraphcore</artifactId>
7-
<version>1.5.12</version>
7+
<version>1.5.13</version>
88

99
<name>NodeGraphCore</name>
1010
<description>Flow based programming in Java.</description>

src/main/java/com/marginallyclever/nodegraphcore/Graph.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ public void removeConnectionsToNode(Node n) {
151151
connections.removeAll(toRemove);
152152
}
153153

154+
/**
155+
* @param node the subject to check
156+
* @return true if the given {@link Node} has any {@link Connection}s to the {@link Input} ports.
157+
*/
158+
public boolean nodeHasInputConnections(Node node) {
159+
for(Connection c : connections) {
160+
for(int i = 0; i<node.getNumPorts(); ++i) {
161+
if(c.getInput() == node.getPort(i)) return true;
162+
}
163+
}
164+
return false;
165+
}
166+
154167
/**
155168
* Searches this {@link Graph} for an equivalent {@link Connection}.
156169
* @param connection the item to match.

src/main/java/com/marginallyclever/nodegraphcore/port/Port.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ public JSONObject toJSON() throws JSONException {
193193
public void fromJSON(JSONObject jo) throws JSONException, ClassCastException {
194194
name = jo.getString("name");
195195
setValue(jo.has("value")
196-
? (T) DAO4JSONFactory.fromJSON(this.type,jo.get("value"))
197-
: null);
196+
? DAO4JSONFactory.fromJSON(this.type,jo.get("value"))
197+
: getValue());
198198
RectangleDAO4JSON dao = new RectangleDAO4JSON();
199199
rectangle.setBounds(dao.fromJSON(jo.getJSONObject("rectangle")));
200200
}

0 commit comments

Comments
 (0)