Hi all,
I´ve made a program where the user can manipulate data with nodes. You can add input, output and different manipulation nodes.
It is like the shader editor from Blender or the program whith which you can program the Siemens Logo PLC.
It works for now but i think it is running very inefficient.
The structure is simply said a bunch of nodes wich are connected via “Interconnections” which take data frome one node and send it to other ones.
The nodes are saved as classes in different ArrayLists depending on which node it is.
The interconnections are also classes in an ArrayList which store the sending and the receiving class type as a string.
And now to my question:
Is it possible to store class types in a variable?
Something like:
Node obj = new Node();
classType ct = obj.getClass();
I think it can be helpful so i wouldnt have to compare strings all the time like in my code (just asnippet, original code is way too long):
for(int i = 0; i<Interconnections.size();i++){
String dataBuffer = "";
Interconnection Ic = Interconnections.get(i);
//--------------------------------------------- from here get the data from nodes
if(Ic.incomingNodeKind.equals("EthernetInputNode")){
for(int j = EthernetInputNodes.size()-1; j>=0;j--){
EthernetInputNode Node = EthernetInputNodes.get(j);
if(Node.ID == Ic.incomingNodeID){
dataBuffer = Node.sendIcData(Ic.incomingNodeLine);
}
}
}
else if(Ic.incomingNodeKind.equals("EthernetOutputNode")){
for(int j = EthernetOutputNodes.size()-1; j>=0;j--){
EthernetOutputNode Node = EthernetOutputNodes.get(j);
if(Node.ID == Ic.incomingNodeID){
dataBuffer = Node.sendIcData(Ic.incomingNodeLine);
}
}
}
else if(Ic.incomingNodeKind.equals("MathNode")){
for(int j = MathNodes.size()-1; j>=0;j--){
MathNode Node = MathNodes.get(j);
if(Node.ID == Ic.incomingNodeID){
dataBuffer = Node.sendIcData(Ic.incomingNodeLine);
}
}
}
//--------------------------------------------- from here send the data to nodes
if(Ic.outgoingNodeKind.equals("EthernetInputNode")){
for(int j = EthernetInputNodes.size()-1; j>=0;j--){
EthernetInputNode Node = EthernetInputNodes.get(j);
if(Node.ID == Ic.outgoingNodeID){
Node.receiveIcData(Ic.outgoingNodeLine, dataBuffer);
}
}
}
else if(Ic.outgoingNodeKind.equals("EthernetOutputNode")){
for(int j = EthernetOutputNodes.size()-1; j>=0;j--){
EthernetOutputNode Node = EthernetOutputNodes.get(j);
if(Node.ID == Ic.outgoingNodeID){
Node.receiveIcData(Ic.outgoingNodeLine, dataBuffer);
}
}
}
else if(Ic.outgoingNodeKind.equals("MathNode")){
for(int j = MathNodes.size()-1; j>=0;j--){
MathNode Node = MathNodes.get(j);
if(Node.ID == Ic.outgoingNodeID){
Node.receiveIcData(Ic.outgoingNodeLine, dataBuffer);
}
}
}
}