diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ConfigurationManager.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ConfigurationManager.java index 1fbcaac81d772d4823c42011b40a246ce02ff402..d564e2090eeb1390ff8ca2e4d79bab943c35bc3e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ConfigurationManager.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ConfigurationManager.java @@ -1,16 +1,16 @@ /******************************************************************************* * Copyright (C) 2017 Philipp Spohr - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -25,9 +25,9 @@ import org.cytoscape.property.AbstractConfigDirPropsReader; import org.cytoscape.property.CyProperty; public class ConfigurationManager extends AbstractConfigDirPropsReader{ - + public ConfigurationManager(String appName, String fileName){ super(appName, fileName, CyProperty.SavePolicy.CONFIG_DIR); - this.getProperties().list(System.out); - } + //this.getProperties().list(System.out); + } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java index a3bb7fa6cf3e324f4dd72c32f0c47081095bca5e..4fed5acd72fa1fa90317556258a1e1fcba0b5fe5 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java @@ -4,12 +4,16 @@ package de.hhu.ba.yoshikoWrapper.core; import java.io.IOException; import org.cytoscape.model.CyColumn; +import org.cytoscape.model.CyNetwork; import org.cytoscape.work.Tunable; import org.cytoscape.work.TunableValidator; public class ParameterSet implements TunableValidator { + @Tunable(description="Network to analyze for clusters", context="nogui") + public CyNetwork net = CyCore.cy.getCurrentNetwork(); + @Tunable(description="Time Limit for the ILP mode", context="nogui") public int timeLimit = -1; @@ -50,16 +54,26 @@ public class ParameterSet implements TunableValidator @Override public ValidationState getValidationState(Appendable errMsg) { - if (!checkBitmask(reductionRulesBitMask)) { - try { - errMsg.append("The Bitmask provided is invalid! Needs to be six bit binary (example: 011001)"); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + System.out.println("DEBUG: Running VALIDATION of tunables"); //TODO: Move to logger (if it would work) + try { + if (net!= null) { + //Verify column validity + CyColumn weightColumn = net.getDefaultEdgeTable().getColumn(weightColumnName); + if (weightColumn == null) { + errMsg.append("Could not find a column named: "+weightColumnName+"\n"); + return ValidationState.INVALID; + } + } + if (!checkBitmask(reductionRulesBitMask)) { + errMsg.append("The Bitmask provided is invalid! Needs to be six bit binary (example: 011001)\n"); + return ValidationState.INVALID; } - return ValidationState.INVALID; + return ValidationState.OK; + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - return ValidationState.OK; + return ValidationState.INVALID; } /** @@ -79,4 +93,5 @@ public class ParameterSet implements TunableValidator return true; } + } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java index 0efd7a5ebe459ca6abf1dea4ce09e1686abab805..2ba55c798ecc670560d3ba5e7e5f1669f3917666 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java @@ -314,7 +314,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { if (YoshikoLoader.isLibraryLoaded()){ AbstractTask yoshiko = new AlgorithmTask( popupLevel, - networkToBeProcessed, fetchParameters(networkToBeProcessed) ); /** @@ -345,6 +344,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent { */ private ParameterSet fetchParameters(CyNetwork net) { ParameterSet ret = new ParameterSet(); + ret.net = net; ret.timeLimit = opModePanel.getTimeLimit(); ret.weightColumnName = ecPanel.getWeightColumn().getName(); ret.permanentColumn = ecPanel.getPermanentColumn(); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java index eab819be1f5b29b128c855e53f36b9b328fc19e9..dfb0eebb8bd3b79d670aff1c0e263905e3923105 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java @@ -185,7 +185,7 @@ NetworkAboutToBeDestroyedListener verticalGroup .addComponent(marker,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(invalidLabel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) - .addComponent(tabbedPane,PREFERRED_SIZE, DEFAULT_SIZE,Short.MAX_VALUE) + .addComponent(tabbedPane,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java index 86650f2e9bc0cff915607b316e3039bd7d516415..83a7ef3ae76973f81b6a4bf2d751de1de2a89d9a 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java @@ -218,8 +218,8 @@ public class SolutionTab extends JPanel { .addGap(8) .addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(hideSingles,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) - .addGap(8) - .addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) + .addGap(4) + .addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addGap(4) ); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/CommandTaskFactory.java b/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/CommandTaskFactory.java index dc9e5cc66d1be0ab208b55a210d73e4f931d7335..ebd95002c5446435990241db14abeee6ce3b0b02 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/CommandTaskFactory.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/CommandTaskFactory.java @@ -45,7 +45,6 @@ public class CommandTaskFactory implements TaskFactory{ else if (command == YoshikoCommand.PERFORM_ALGORITHM) { return new TaskIterator( new AlgorithmTask( - null, null, new ParameterSet() ) diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java index cbc64bb4d4c4a3a8afcfa969ec50940d393701ae..31ea1ea1c33c23d839589d2a3aa2496c32d4817b 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java @@ -77,8 +77,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { @ContainsTunables public ParameterSet parameterSet = null; - @Tunable(description="Network to analyze for clusters", context="nogui") - public CyNetwork net = CyCore.cy.getCurrentNetwork(); + //Temps, pointing to and need to be freed in C++ private LibraryInput c_input; @@ -98,12 +97,10 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { */ public AlgorithmTask( Window statusWindow, - CyNetwork net, ParameterSet parameterSet ) { this.statusWindow = statusWindow; - this.net = net; this.parameterSet = parameterSet; } @@ -115,8 +112,8 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { taskMonitor.setTitle(LocalizationManager.get("yoshTask")); taskMonitor.setProgress(0.0); - //Get current network - if (net == null) { + //Check current network + if (parameterSet.net == null) { logger.warn("CoreAlgorithm called on a net that is NULL!"); throw new Exception("CoreAlgorithm called on a net that is NULL!"); //TODO: Localize } @@ -131,14 +128,14 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { } //Create a node map to identify nodes and eges in the solution - NodeMap nodeMap = new NodeMap(net); + NodeMap nodeMap = new NodeMap(parameterSet.net); taskMonitor.setProgress(0.1); //Generate an c_input instance from the network c_input = NetworkParser.parseNetwork( - net, + parameterSet.net, nodeMap, - net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName), + parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName), //Simplify parameterSet.permanentColumn, parameterSet.forbiddenColumn, parameterSet.defaultDeletionCost @@ -146,8 +143,8 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { taskMonitor.setProgress(0.2); boolean containsRealValues = GraphAnalyzer.containsRealValues( - net, - net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName), + parameterSet.net, + parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.weightColumnName), parameterSet.permanentColumn, parameterSet.forbiddenColumn, parameterSet.defaultInsertionCost, @@ -184,7 +181,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!"); //TODO: Localize - result = new YoshikoResult(net,c_result.getFlags()); + result = new YoshikoResult(parameterSet.net,c_result.getFlags()); //Loop over (multiple) solutions for (long i=0;i<numberOfSolutions;i++) { @@ -195,8 +192,8 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { String columnName = SOLUTION_COLUMN_PREFIX+(i+1); - net.getDefaultNodeTable().deleteColumn(columnName); - net.getDefaultNodeTable().createColumn(columnName, String.class, false); + parameterSet.net.getDefaultNodeTable().deleteColumn(columnName); + parameterSet.net.getDefaultNodeTable().createColumn(columnName, String.class, false); //Fetch number of clusters in the solution long numberOfClusters = c_result.getNumberOfClusters(i); @@ -218,7 +215,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { CyNode node = nodeMap.indexOf(nodeID); //<<< Another int/long conversion cluster.addNode(node); - net.getRow(node).set(columnName, ""+(k+1)); //Add Cluster ID in table (Remove in final version?) + parameterSet.net.getRow(node).set(columnName, ""+(k+1)); //Add Cluster ID in table (Remove in final version?) } //Register clusters with solution for further reference solution.addCluster(cluster);