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