Skip to content
Snippets Groups Projects
Commit 769f86cd authored by unknown's avatar unknown
Browse files

implemented progress-bar

parent b5929a70
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ package de.hhu.ba.yoshikoWrapper; ...@@ -23,6 +23,7 @@ package de.hhu.ba.yoshikoWrapper;
import java.util.Properties; import java.util.Properties;
import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask;
import org.cytoscape.application.CyApplicationManager; import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.swing.CySwingApplication; import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelComponent;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
******************************************************************************/ ******************************************************************************/
package de.hhu.ba.yoshikoWrapper.core; package de.hhu.ba.yoshikoWrapper.core;
import java.awt.*;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import de.hhu.ba.yoshikoWrapper.swing.components.MainPanel; import de.hhu.ba.yoshikoWrapper.swing.components.MainPanel;
...@@ -39,10 +40,7 @@ import org.cytoscape.view.presentation.RenderingEngineFactory; ...@@ -39,10 +40,7 @@ import org.cytoscape.view.presentation.RenderingEngineFactory;
import org.cytoscape.view.vizmap.VisualMappingFunctionFactory; import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
import org.cytoscape.view.vizmap.VisualMappingManager; import org.cytoscape.view.vizmap.VisualMappingManager;
import org.cytoscape.view.vizmap.VisualStyleFactory; import org.cytoscape.view.vizmap.VisualStyleFactory;
import org.cytoscape.work.FinishStatus; import org.cytoscape.work.*;
import org.cytoscape.work.ObservableTask;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.TaskObserver;
import org.cytoscape.work.swing.DialogTaskManager; import org.cytoscape.work.swing.DialogTaskManager;
...@@ -71,7 +69,11 @@ public class CyCore { ...@@ -71,7 +69,11 @@ public class CyCore {
public static CommandExecutorTaskFactory commandExecutorTaskFactory; public static CommandExecutorTaskFactory commandExecutorTaskFactory;
// //
//ugly passing of variables
public static MainPanel mainPanel; public static MainPanel mainPanel;
public static TaskMonitor taskMonitor;
public static Window statusWindow;
//Convenience //Convenience
// public static String getConfig(String key) { // public static String getConfig(String key) {
// return cm.getProperties().getProperty(key); // return cm.getProperties().getProperty(key);
...@@ -83,18 +85,6 @@ public class CyCore { ...@@ -83,18 +85,6 @@ public class CyCore {
* @throws InterruptedException * @throws InterruptedException
*/ */
public static synchronized void runAndWait(TaskIterator taskIterator) throws InterruptedException { public static synchronized void runAndWait(TaskIterator taskIterator) throws InterruptedException {
CountDownLatch blockLatch = new CountDownLatch(1); dialogTaskManager.execute(taskIterator);
dialogTaskManager.execute(taskIterator,new TaskObserver() {
@Override
public void taskFinished(ObservableTask task) {}
@Override
public void allFinished(FinishStatus finishStatus) {
blockLatch.countDown();
}
});
blockLatch.await();
} }
} }
...@@ -235,6 +235,8 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -235,6 +235,8 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
popupLevel.setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE); popupLevel.setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
statusWindow.setModalityType(ModalityType.MODELESS); statusWindow.setModalityType(ModalityType.MODELESS);
statusWindow.setAlwaysOnTop(false); statusWindow.setAlwaysOnTop(false);
CyCore.statusWindow = statusWindow;
//SWING BLACK MAGIC //SWING BLACK MAGIC
CommandTaskFactory commandTaskFactory = new CommandTaskFactory(YoshikoCommand.PERFORM_ALGORITHM); CommandTaskFactory commandTaskFactory = new CommandTaskFactory(YoshikoCommand.PERFORM_ALGORITHM);
......
...@@ -22,36 +22,20 @@ ...@@ -22,36 +22,20 @@
package de.hhu.ba.yoshikoWrapper.tasks; package de.hhu.ba.yoshikoWrapper.tasks;
import java.awt.Window; import java.awt.Window;
import java.util.Properties;
import de.hhu.ba.yoshikoWrapper.swing.components.MainPanel;
import de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm.YoshikoAlgoritmController; import de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm.YoshikoAlgoritmController;
import org.cytoscape.application.swing.CytoPanel;
import org.cytoscape.application.swing.CytoPanelName;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyTable;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.view.layout.CyLayoutAlgorithm;
import org.cytoscape.work.AbstractTask; import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.ContainsTunables; import org.cytoscape.work.ContainsTunables;
import org.cytoscape.work.ObservableTask;
import org.cytoscape.work.TaskMonitor; import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.TunableValidator;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger; import org.slf4j.Logger;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.ParameterSet; import de.hhu.ba.yoshikoWrapper.core.ParameterSet;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult; import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult;
import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
import de.hhu.ba.yoshikoWrapper.swing.components.ResultPanel; import de.hhu.ba.yoshikoWrapper.swing.components.ResultPanel;
public class AlgorithmTask extends AbstractTask implements ObservableTask, TunableValidator { public class AlgorithmTask extends AbstractTask {
//Constants //Constants
private static final String SOLUTION_COLUMN_PREFIX = "yoshikoSolution_"; //TODO: Make customizable? private static final String SOLUTION_COLUMN_PREFIX = "yoshikoSolution_"; //TODO: Make customizable?
...@@ -91,11 +75,9 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab ...@@ -91,11 +75,9 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab
} }
@Override @Override
public void run(TaskMonitor taskMonitor) throws Exception { public void run(final TaskMonitor taskMonitor) throws Exception {
//TODO: Improve setProgress values //TODO: Improve setProgress values
taskMonitor.setTitle("yoshTask");
taskMonitor.setTitle(LocalizationManager.get("yoshTask"));
taskMonitor.setProgress(0.0);
//Check current network //Check current network
if (parameterSet.net == null) { if (parameterSet.net == null) {
...@@ -103,8 +85,11 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab ...@@ -103,8 +85,11 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab
throw new Exception("CoreAlgorithm called on a net that is NULL!"); //TODO: Localize throw new Exception("CoreAlgorithm called on a net that is NULL!"); //TODO: Localize
} }
YoshikoAlgoritmController yoshikoAlgoritmController = new YoshikoAlgoritmController(parameterSet); YoshikoAlgoritmController yoshikoAlgoritmController = new YoshikoAlgoritmController(parameterSet, taskMonitor);
yoshikoAlgoritmController.controllAlgorithm(); yoshikoAlgoritmController.controllAlgorithm();
taskMonitor.setProgress(1);
/* /*
...@@ -166,7 +151,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab ...@@ -166,7 +151,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab
} }
/*
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <R> R getResults(Class<? extends R> type) { public <R> R getResults(Class<? extends R> type) {
...@@ -176,10 +161,10 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab ...@@ -176,10 +161,10 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab
} }
return null; return null;
} }
*//*
@Override @Override
public ValidationState getValidationState(Appendable errMsg) { public ValidationState getValidationState(Appendable errMsg) {
//In order to validate the arguments for this task we simply check the ParameterSet //In order to validate the arguments for this task we simply check the ParameterSet
return parameterSet.getValidationState(errMsg); return parameterSet.getValidationState(errMsg);
} }*/
} }
package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm;
import org.cytoscape.work.TaskMonitor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -10,28 +12,37 @@ public class ClusteringAlgorithm { ...@@ -10,28 +12,37 @@ public class ClusteringAlgorithm {
private double clusteringCost; private double clusteringCost;
private YoshikoEdge[][] edgeArray; private YoshikoEdge[][] edgeArray;
private int numberOfNodes; private int numberOfNodes;
List<Integer> nodeList; private List<Integer> nodeList;
List<List<Integer>> clusters; private List<List<Integer>> clusters;
int k=-1; int k=-1;
int nodeInClusters; private int nodeInClusters;
private TaskMonitor taskMonitor;
public ClusteringAlgorithm(YoshikoEdge[][] edgeArray){ public ClusteringAlgorithm(YoshikoEdge[][] edgeArray, TaskMonitor taskMonitor){
this.edgeArray = edgeArray; this.edgeArray = edgeArray;
numberOfNodes = edgeArray.length; numberOfNodes = edgeArray.length;
clusters = new ArrayList<>(); clusters = new ArrayList<>();
this.taskMonitor = taskMonitor;
clusteringCost = 0; clusteringCost = 0;
} }
public List<List<Integer>> runClusteringAlgorithm(){ public List<List<Integer>> runClusteringAlgorithm(){
initializeQueue(); initializeQueue();
double initialBHeapSize = bHeap.size();
if (k < 0) { if (k < 0) {
while (bHeap.size() > 0) { while (bHeap.size() > 0) {
double progress = (initialBHeapSize-bHeap.size())/initialBHeapSize;
taskMonitor.setProgress(progress);
workHeap(); workHeap();
} }
}else { }else {
while (numberOfNodes-nodeInClusters > k) { while (numberOfNodes-nodeInClusters > k) {
double progress = (initialBHeapSize-bHeap.size())/initialBHeapSize;
taskMonitor.setProgress(progress);
workHeap(); workHeap();
} }
} }
...@@ -129,7 +140,6 @@ public class ClusteringAlgorithm { ...@@ -129,7 +140,6 @@ public class ClusteringAlgorithm {
private void workHeap(){ private void workHeap(){
System.out.println(bHeap.size());
YoshikoEdge e=bHeap.popMax(); YoshikoEdge e=bHeap.popMax();
...@@ -172,8 +182,6 @@ public class ClusteringAlgorithm { ...@@ -172,8 +182,6 @@ public class ClusteringAlgorithm {
addInfluenceOfVertexOnIcfIcp(e.source); addInfluenceOfVertexOnIcfIcp(e.source);
putInCluster(e); putInCluster(e);
System.out.println("perm");
} }
private void mergeVertexes(YoshikoEdge e){ private void mergeVertexes(YoshikoEdge e){
...@@ -323,7 +331,6 @@ public class ClusteringAlgorithm { ...@@ -323,7 +331,6 @@ public class ClusteringAlgorithm {
e.weight=Double.NEGATIVE_INFINITY; e.weight=Double.NEGATIVE_INFINITY;
bHeap.remove(e); bHeap.remove(e);
System.out.println("rm");
} }
private void editInfluenzeOfForbiddenEdge(YoshikoEdge forbiddenEdge){ private void editInfluenzeOfForbiddenEdge(YoshikoEdge forbiddenEdge){
......
...@@ -2,6 +2,7 @@ package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; ...@@ -2,6 +2,7 @@ package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm;
import de.hhu.ba.yoshikoWrapper.core.ParameterSet; import de.hhu.ba.yoshikoWrapper.core.ParameterSet;
import org.cytoscape.model.CyNetwork; import org.cytoscape.model.CyNetwork;
import org.cytoscape.work.TaskMonitor;
import java.util.List; import java.util.List;
...@@ -10,24 +11,28 @@ public class YoshikoAlgoritmController { ...@@ -10,24 +11,28 @@ public class YoshikoAlgoritmController {
private int k; private int k;
private CyNetwork network; private CyNetwork network;
private ParameterSet parameterSet; private ParameterSet parameterSet;
private TaskMonitor taskMonitor;
public YoshikoAlgoritmController(ParameterSet parameterSet){ public YoshikoAlgoritmController(ParameterSet parameterSet, TaskMonitor taskMonitor){
this.parameterSet = parameterSet; this.parameterSet = parameterSet;
this.network = parameterSet.net; this.network = parameterSet.net;
this.k = parameterSet.clusterCount; this.k = parameterSet.clusterCount;
this.taskMonitor = taskMonitor;
} }
public void controllAlgorithm(){ public void controllAlgorithm(){
GraphTranslator translator = new GraphTranslator(parameterSet); GraphTranslator translator = new GraphTranslator(parameterSet);
YoshikoEdge[][] edgeArray = translator.translateGraph(); YoshikoEdge[][] edgeArray = translator.translateGraph();
ClusteringAlgorithm clusteringAlgorithm = new ClusteringAlgorithm(edgeArray); ClusteringAlgorithm clusteringAlgorithm = new ClusteringAlgorithm(edgeArray, taskMonitor);
clusteringAlgorithm.k = k; clusteringAlgorithm.k = k;
List<List<Integer>> clusters; List<List<Integer>> clusters;
taskMonitor.setStatusMessage("Clustering the Graph");
clusters = clusteringAlgorithm.runClusteringAlgorithm(); clusters = clusteringAlgorithm.runClusteringAlgorithm();
taskMonitor.setStatusMessage("Makeing new Graph");
translator.makeCytoscapeGraph(clusters); translator.makeCytoscapeGraph(clusters);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment