diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java index ee46985628ef545a62f94a0bcc99ef35cd0dea26..15bcfce642a3f08f6056fdc9fb297cd3fd7e4c87 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java @@ -127,6 +127,13 @@ public class CyActivator extends AbstractCyActivator { props_GET_SOLUTIONS.setProperty(COMMAND_DESCRIPTION,"Retrieve solutions associated with a result"); registerService(context, commandTaskFactory_GET_SOLUTIONS, TaskFactory.class, props_GET_SOLUTIONS); + TaskFactory commandTaskFactory_GET_CLUSTERS = new CommandTaskFactory(YoshikoCommand.GET_CLUSTERS); + Properties props_GET_CLUSTERS = new Properties(); + props_GET_CLUSTERS.setProperty(COMMAND_NAMESPACE, "yoshiko"); + props_GET_CLUSTERS.setProperty(COMMAND, YoshikoCommand.GET_CLUSTERS.toString()); + props_GET_CLUSTERS.setProperty(COMMAND_DESCRIPTION,"Retrieve clusters associated with a solution"); + registerService(context, commandTaskFactory_GET_CLUSTERS, TaskFactory.class, props_GET_CLUSTERS); + //Initialize and register main panel MainPanel mainPanel = new MainPanel(); registerService(context,mainPanel,CytoPanelComponent.class, new Properties()); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java index 47f1c4dd49dff15317072a6eda3b8834c9733887..0a4ea3bb435ac149f946368b277bbdfe2a9e1498 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java @@ -88,4 +88,8 @@ public class YoshikoResult{ return id; } + public YoshikoSolution getSolution(long solutionID) { + return solutions.get(solutionID); + } + } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java index bf8eb5e9593860b31072e143eafc8337150d25a0..1a2024545425a27700c38d06d47bed5021d201a7 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java @@ -22,7 +22,6 @@ package de.hhu.ba.yoshikoWrapper.graphModel; import java.util.Collection; -import java.util.Comparator; import java.util.HashMap; import java.util.List; 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 53e7fbbdd14a5ec4f28ecf0a643e6d4afef80bcd..dc9e5cc66d1be0ab208b55a210d73e4f931d7335 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/CommandTaskFactory.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/CommandTaskFactory.java @@ -4,9 +4,7 @@ import org.cytoscape.work.TaskFactory; import org.cytoscape.work.TaskIterator; import de.hhu.ba.yoshikoWrapper.core.ParameterSet; -import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask; -import de.hhu.ba.yoshikoWrapper.tasks.CreateClusterViewsTask; -import de.hhu.ba.yoshikoWrapper.tasks.GetSolutionsTask; +import de.hhu.ba.yoshikoWrapper.tasks.*; public class CommandTaskFactory implements TaskFactory{ @@ -39,7 +37,11 @@ public class CommandTaskFactory implements TaskFactory{ new GetSolutionsTask() ); } - + else if (command == YoshikoCommand.GET_CLUSTERS) { + return new TaskIterator( + new GetClustersTask() + ); + } else if (command == YoshikoCommand.PERFORM_ALGORITHM) { return new TaskIterator( new AlgorithmTask( diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/YoshikoCommand.java b/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/YoshikoCommand.java index 25ead63a2f857fff895d91e36d1c54a166f63fdc..3f4913cc2642e0840a8c9690f75a6f301e87b4e9 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/YoshikoCommand.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/YoshikoCommand.java @@ -12,7 +12,8 @@ public enum YoshikoCommand { CREATE_CLUSTER_VIEW, CREATE_META_GRAPH, PERFORM_ALGORITHM, - GET_SOLUTIONS; + GET_SOLUTIONS, + GET_CLUSTERS; @Override public String toString() { @@ -22,6 +23,9 @@ public enum YoshikoCommand { else if (this==CREATE_CLUSTER_VIEW) { return "createcvs"; } + else if (this==GET_CLUSTERS) { + return "clusters"; //TODO: maybe smarter names for the commands + } else if (this==GET_SOLUTIONS) { return "solutions"; } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java index 78888ae59398abce065e4db6c3ba544c0b9305dc..9975bbaa8b583f5a6947a2bf83a1168b3cf3ca50 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetClustersTask.java @@ -1,6 +1,6 @@ package de.hhu.ba.yoshikoWrapper.tasks; -import java.util.ArrayList; +import java.util.Collection; import org.cytoscape.work.ObservableTask; import org.cytoscape.work.TaskMonitor; @@ -17,9 +17,9 @@ public class GetClustersTask implements ObservableTask { public int resultID = -1; @Tunable(description="The solution ID for which the solutions should be displayed", context="nogui") - public int solutionID = -1; + public long solutionID = -1; - private ArrayList<YoshikoCluster> clusters; + private Collection<YoshikoCluster> clusters; @Override public void run(TaskMonitor taskMonitor) throws Exception { @@ -27,11 +27,14 @@ public class GetClustersTask implements ObservableTask { if (result == null) { throw new Exception("No result with ID: "+resultID+" was found!"); //TODO: Localization } + if (result.getSolution(solutionID)== null) { + throw new Exception("No solution with ID: "+solutionID+" was found!"); //TODO: Localization + } + clusters = result.getSolution(solutionID).getClusters(); } @Override public void cancel() { - // TODO Auto-generated method stub } @@ -40,7 +43,9 @@ public class GetClustersTask implements ObservableTask { public <R> R getResults(Class<? extends R> type) { if (type.equals(String.class)) { String ret = ""; - + for (YoshikoCluster c: clusters) { + ret+="Cluster[ID="+c.getID()+"]: "+c.getSize()+" nodes\n"; + } return (R) ret; } return null;