Skip to content

Commit

Permalink
Undoing.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanmg committed Aug 27, 2020
1 parent a3dc481 commit d49c9da
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions NeuGen/src/org/neugen/backend/NGBackend.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import org.neugen.datastructures.Net;
import org.neugen.datastructures.Region;
import org.neugen.datastructures.xml.XMLObject;
import org.neugen.datastructures.xml.XMLNode;
import org.neugen.gui.NeuGenConstants;
import org.neugen.gui.NeuGenLib;
import org.neugen.gui.NeuGenProject;
Expand Down Expand Up @@ -362,7 +363,7 @@ public void create_and_open_project(String projectPath, String sourceTemplate, S
* @param currentRoot
* @param projectDirPath
*/
private void save_param(TreeNode currentRoot, String projectDirPath) {
private void save_param(XMLNode currentRoot, String projectDirPath) {
save(currentRoot, projectDirPath, NeuGenConstants.PARAM);
}

Expand All @@ -371,7 +372,7 @@ private void save_param(TreeNode currentRoot, String projectDirPath) {
* @param currentRoot
* @param projectDirPath
*/
private void save_interna(TreeNode currentRoot, String projectDirPath) {
private void save_interna(XMLNode currentRoot, String projectDirPath) {
save(currentRoot, projectDirPath, NeuGenConstants.INTERNA);
}

Expand All @@ -391,7 +392,7 @@ public void save(Map<String, XMLObject> paramTrees, String projectDirPath) {
* @param projectDirPath
* @param param
*/
private void save(TreeNode currentRoot, String projectDirPath, String param) {
private void save(XMLNode currentRoot, String projectDirPath, String param) {
logger.info("leaf count: " + currentRoot.getLeafCount());

/**
Expand Down Expand Up @@ -579,23 +580,23 @@ public void modifyNPartsDensity(double density) {
for (Map.Entry<String, XMLObject> entry : params.entrySet()) {
XMLObject obj = entry.getValue();

Enumeration<TreeNode> childs = obj.children();
Enumeration<XMLNode> childs = obj.children();

while (childs.hasMoreElements()) {
TreeNode node = childs.nextElement();
XMLNode node = childs.nextElement();
if ("neuron".equals(node.toString())) {
Enumeration<TreeNode> childs2 = node.children();
Enumeration<XMLNode> childs2 = node.children();
while (childs2.hasMoreElements()) {
TreeNode node2 = childs2.nextElement();
XMLNode node2 = childs2.nextElement();
if ("axon".equals(node2.toString())) {
Enumeration<TreeNode> childs3 = node2.children();
Enumeration<XMLNode> childs3 = node2.children();
while (childs3.hasMoreElements()) {
TreeNode child4 = childs3.nextElement();
XMLNode child4 = childs3.nextElement();
if ("gen_0".equals(child4.toString())) {
Enumeration<TreeNode> childs5 = child4.children();
Enumeration<XMLNode> childs5 = child4.children();

while (childs5.hasMoreElements()) {
TreeNode child6 = childs5.nextElement();
XMLNode child6 = childs5.nextElement();

if ("nparts_density".equals(child6.getKey())) {
System.err.println("child6 (before): " + child6.toString());
Expand All @@ -617,15 +618,15 @@ public void modifyNPartsDensity(double density) {

} else if ("dendrite".equals(node2.toString())) {

Enumeration<TreeNode> childs3 = node2.children();
Enumeration<XMLNode> childs3 = node2.children();
while (childs3.hasMoreElements()) {
TreeNode child4 = childs3.nextElement();
XMLNode child4 = childs3.nextElement();
System.err.println("axon child: " + child4.toString());
if ("gen_0".equals(child4.toString())) {
Enumeration<TreeNode> childs5 = child4.children();
Enumeration<XMLNode> childs5 = child4.children();

while (childs5.hasMoreElements()) {
TreeNode child6 = childs5.nextElement();
XMLNode child6 = childs5.nextElement();

if ("nparts_density".equals(child6.getKey())) {
System.err.println("child6 (before): " + child6.toString());
Expand Down Expand Up @@ -663,15 +664,15 @@ public void modifySynapseDistance(double dist_synapse) {
for (Map.Entry<String, XMLObject> entry : params.entrySet()) {
XMLObject obj = entry.getValue();
@SuppressWarnings("unchecked")
Enumeration<TreeNode> childs = obj.children();
Enumeration<XMLNode> childs = obj.children();

while (childs.hasMoreElements()) {
TreeNode node = childs.nextElement();
XMLNode node = childs.nextElement();
if ("net".equals(node.toString())) {
@SuppressWarnings("unchecked")
Enumeration<TreeNode> childs2 = node.children();
Enumeration<XMLNode> childs2 = node.children();
while (childs2.hasMoreElements()) {
TreeNode node2 = childs2.nextElement();
XMLNode node2 = childs2.nextElement();
if ("dist_synapse".equals(node2.getKey())) {
node2.setValue(dist_synapse);
}
Expand All @@ -693,15 +694,15 @@ public void adjustNetworkSize(int factor) {
for (Map.Entry<String, XMLObject> entry : params.entrySet()) {
XMLObject obj = entry.getValue();
@SuppressWarnings("unchecked")
Enumeration<TreeNode> childs = obj.children();
Enumeration<XMLNode> childs = obj.children();

while (childs.hasMoreElements()) {
TreeNode node = childs.nextElement();
XMLNode node = childs.nextElement();
if ("net".equals(node.toString())) {
@SuppressWarnings("unchecked")
Enumeration<TreeNode> childs2 = node.children();
Enumeration<XMLNode> childs2 = node.children();
while (childs2.hasMoreElements()) {
TreeNode node2 = childs2.nextElement();
XMLNode node2 = childs2.nextElement();
if (! "dist_synapse".equals(node2.getKey())) {
node2.setValue(Integer.parseInt(node2.getValue().toString()) * factor);
}
Expand Down Expand Up @@ -769,14 +770,14 @@ private void adjust_cell_number_for_cell_type(String cellType, int numberOfCells
for (Map.Entry<String, XMLObject> entry : params.entrySet()) {
XMLObject obj = entry.getValue();
@SuppressWarnings("unchecked")
Enumeration<TreeNode> childs = obj.children();
Enumeration<XMLNode> childs = obj.children();
while (childs.hasMoreElements()) {
TreeNode node = childs.nextElement();
XMLNode node = childs.nextElement();
if ("net".equals(node.toString())) {
@SuppressWarnings("unchecked")
Enumeration<TreeNode> childs2 = node.children();
Enumeration<XMLNode> childs2 = node.children();
while (childs2.hasMoreElements()) {
TreeNode node2 = childs2.nextElement();
XMLNode node2 = childs2.nextElement();
if (cellType.equals(node2.getKey())) {
node2.setValue(numberOfCells);
}
Expand Down Expand Up @@ -853,10 +854,10 @@ private void modifyParameter(XMLObject paramTree, double param, String identifie
}

ArrayList<String> pathes = new ArrayList<String>(Arrays.asList(identifier.split("/")));
Enumeration<TreeNode> childs = paramTree.children();
Enumeration<XMLNode> childs = paramTree.children();

while (childs.hasMoreElements()) {
TreeNode node = childs.nextElement();
XMLNode node = childs.nextElement();
if (pathes.get(0).equals(node.getKey())) {
modifyParameter_rec(node,
param,
Expand All @@ -876,10 +877,10 @@ private void modifyParameter(XMLObject paramTree, double param, String identifie
* @param identifier
*/
@SuppressWarnings("unchecked")
private void modifyParameter_rec(TreeNode root, double param, ArrayList<String> identifier) {
Enumeration<TreeNode> childs = root.children();
private void modifyParameter_rec(XMLNode root, double param, ArrayList<String> identifier) {
Enumeration<XMLNode> childs = root.children();
while (childs.hasMoreElements()) {
TreeNode node = childs.nextElement();
XMLNode node = childs.nextElement();
if (identifier.get(0).equals(node.getKey())) {
if (identifier.size() == 1) {
node.setValue(param);
Expand All @@ -903,15 +904,15 @@ private void modifyParameter_rec(TreeNode root, double param, ArrayList<String>
* @param replacement
*/
@SuppressWarnings("unchecked")
private void correct_siblings(TreeNode child, String identifier, double replacement) {
/// only one child called siblings within childs of current TreeNode child
Enumeration<TreeNode> childs = child.children();
TreeNode sibling = childs.nextElement();
Enumeration<TreeNode> childs_of_sibling = sibling.children();
private void correct_siblings(XMLNode child, String identifier, double replacement) {
/// only one child called siblings within childs of current XMLNode child
Enumeration<XMLNode> childs = child.children();
XMLNode sibling = childs.nextElement();
Enumeration<XMLNode> childs_of_sibling = sibling.children();

while (childs_of_sibling.hasMoreElements()) {
/// current child of current sibling's child
TreeNode current_child = childs_of_sibling.nextElement();
XMLNode current_child = childs_of_sibling.nextElement();

/// replace node's content
if (identifier.equals(current_child.getKey())) {
Expand Down

0 comments on commit d49c9da

Please sign in to comment.