Skip to content
Snippets Groups Projects
Commit fe40935e authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Rough but working presentation of solutions

parent c8a7cf2e
Branches
Tags
No related merge requests found
......@@ -15,7 +15,6 @@ import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_std__vectorT_int_t;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_yskInput__LibraryInput;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_ysk__ClusterEditingSolutions;
public class AlgorithmTask extends AbstractTask {
......@@ -101,7 +100,7 @@ public class AlgorithmTask extends AbstractTask {
LibraryInterface.LibraryInput_setDefaultInsertionCost(input, insertionCostDefault);
//Call Yoshiko <<< Algorithm is performed here
SWIGTYPE_p_ysk__ClusterEditingSolutions solutions = LibraryInterface.processLibraryInput(
CyCore.currentSolutions = LibraryInterface.processLibraryInput(
input,
1,
bitMaskRules,
......@@ -115,11 +114,11 @@ public class AlgorithmTask extends AbstractTask {
this.solutionsPanel.reset();
long numberOfSolutions = LibraryInterface.ClusterEditingSolutions_getNumberOfSolutions(solutions);
long numberOfSolutions = LibraryInterface.ClusterEditingSolutions_getNumberOfSolutions(CyCore.currentSolutions);
taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!");
double modificationCost = LibraryInterface.ClusterEditingSolutions_getTotalCost(solutions);
taskMonitor.setStatusMessage("Paid a total modification cost of: "+modificationCost);
double modificationCost = LibraryInterface.ClusterEditingSolutions_getTotalCost(CyCore.currentSolutions);
taskMonitor.setStatusMessage(LocalizationManager.get("paidCost")+modificationCost);
for (long i=0;i<numberOfSolutions;i++) {
......@@ -131,13 +130,14 @@ public class AlgorithmTask extends AbstractTask {
net.getDefaultNodeTable().deleteColumn(columnName);
net.getDefaultNodeTable().createColumn(columnName, String.class, false);
long numberOfClusters = LibraryInterface.ClusterEditingSolutions_getNumberOfClusters(solutions, i);
long numberOfClusters = LibraryInterface.ClusterEditingSolutions_getNumberOfClusters(CyCore.currentSolutions, i);
tab.setClusterNumber(numberOfClusters);
for (long k=0;k<numberOfClusters;k++) {
ClusterView cV = tab.addCluster(k);
cV.setTitle((k+1));
taskMonitor.setStatusMessage("Processing cluster "+(k+1)+" of "+numberOfClusters);
SWIGTYPE_p_std__vectorT_int_t cluster = LibraryInterface.ClusterEditingSolutions_getCluster(solutions, i, k);
SWIGTYPE_p_std__vectorT_int_t cluster = LibraryInterface.ClusterEditingSolutions_getCluster(CyCore.currentSolutions, i, k);
long sizeOfCluster = LibraryInterface.IntVector_size(cluster);
cV.setClusterSize(sizeOfCluster);
for (int l=0;l<sizeOfCluster;l++) { //Unsafe mismatch int long
......@@ -154,9 +154,6 @@ public class AlgorithmTask extends AbstractTask {
}
}
solutionsPanel.revalidate();
solutionsPanel.repaint();
LibraryInterface.delete_LibraryInput(input);
taskMonitor.setProgress(1.0);
}
......
......@@ -3,8 +3,11 @@ package de.hhu.ba.yoshikoWrapper.core;
import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.work.swing.DialogTaskManager;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_ysk__ClusterEditingSolutions;
public class CyCore {
public static CyApplicationManager cy;
public static DialogTaskManager dialogTaskManager;
public static ConfigurationManager cm;
public static SWIGTYPE_p_ysk__ClusterEditingSolutions currentSolutions;
}
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.border.Border;
import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyRow;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial")
......@@ -14,33 +24,87 @@ public class ClusterView extends ComfortPanel {
private final JLabel title;
private final JLabel clusterSize;
private JList<String> nodeList;
private final Border regularBorder = BorderFactory.createLineBorder(Color.GRAY);
private final Border highlightBorder = BorderFactory.createLineBorder(Color.RED);
//SYMBOLIC LINKS
/**Simple array list containing references to the nodes that are represented by this cluster view
*
*/
private ArrayList<CyNode> nodes;
public ClusterView() {
//Swing init
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
this.title = new JLabel("CLUSTERTITLE");
this.clusterSize = new JLabel("CLUSTERLABEL");
this.nodeList = new JList<String>();
title = new JLabel("CLUSTERTITLE");
clusterSize = new JLabel("CLUSTERLABEL");
this.addAll(title,clusterSize,nodeList);
this.addAll(title,clusterSize);
this.add(Box.createVerticalStrut(4));
this.addMouseListener(mouseListener);
this.setBorder(regularBorder);
//Other init
nodes = new ArrayList<CyNode>();
}
public void addNode(CyNode node) {
this.add(
new JLabel(
CyCore.cy.getCurrentNetwork().getRow(node).get("name", String.class)
)
);
//Add symbolic link
nodes.add(node);
}
public void setTitle(long x) {
this.title.setText(LocalizationManager.get("cluster")+" "+x);
revalidate();
repaint();
}
public void setClusterSize(long x) {
this.clusterSize.setText(LocalizationManager.get("clusterSize")+" "+x);
revalidate();
repaint();
}
public void addNode(CyNode node) {
this.nodeList.add(new JLabel(node.toString()));
revalidate();
repaint();
private MouseListener mouseListener = new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {}
@Override
public void mousePressed(MouseEvent e) {
//Undo previous selection
List<CyRow> allRows = CyCore.cy.getCurrentNetwork().getDefaultNodeTable().getAllRows();
for (CyRow r: allRows) {
r.set("selected", false);
}
//Select nodes corresponding to the cluster
for (CyNode n : nodes) {
CyCore.cy.getCurrentNetwork().getRow(n).set("selected", true);
}
}
@Override
public void mouseReleased(MouseEvent e) {}
@Override
public void mouseEntered(MouseEvent e) {
setBorder(highlightBorder);
}
@Override
public void mouseExited(MouseEvent e) {
setBorder(regularBorder);
}
};
}
......@@ -21,6 +21,7 @@ import de.hhu.ba.yoshikoWrapper.core.AlgorithmTask;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
/**This class describes the Swing Panel that the user interacts with in cytoscape
* @author Philipp Spohr, Aug 6, 2017
......@@ -85,12 +86,48 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
JButton runButton = new JButton("RUN");
runButton.addActionListener(new ActionListener() {
runButton.addActionListener(buttonListener);
this.addAll(
langSwitcher,
libraryPanel,
ecPanel,
useILP,
useHeuristic,
timeLimitSetter,
reductionRulesChooser,
useTriangleCutsBox,
usePartitionCutsBox,
runButton
);
this.setVisible(true);
}
/**
* ButtonListener for the "Run" Button
* Handles calling the algorithm and fetching/passing the arguments from swing components
*/
private ActionListener buttonListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (YoshikoLoader.isLibraryLoaded()){
//Check if a solution exists, WARN THE USER!!!
if (CyCore.currentSolutions != null) {
int dialogResult = JOptionPane.showConfirmDialog (
null,
LocalizationManager.get("overrideSolution"),
LocalizationManager.get("warning"),
JOptionPane.YES_NO_OPTION
);
if (dialogResult != JOptionPane.YES_OPTION) {
return;
}
LibraryInterface.delete_ClusterEditingSolutions(CyCore.currentSolutions);
}
solutionsPanel.setVisible(false);
AbstractTask yoshiko = new AlgorithmTask(
CyCore.cy.getCurrentNetwork(),
timeLimitSetter.getTimeLimit(),
......@@ -118,26 +155,7 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
);
}
}
});
this.addAll(
langSwitcher,
libraryPanel,
ecPanel,
useILP,
useHeuristic,
timeLimitSetter,
reductionRulesChooser,
useTriangleCutsBox,
usePartitionCutsBox,
runButton
);
this.setVisible(true);
}
};
//GETTER / SETTER
......@@ -146,7 +164,6 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
return this;
}
/* (non-Javadoc)
* @see org.cytoscape.application.swing.CytoPanelComponent#getCytoPanelName()
*/
......
......@@ -6,6 +6,9 @@ import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial")
public class ReductionRulesChooser extends ComfortPanel{
......@@ -35,7 +38,7 @@ public class ReductionRulesChooser extends ComfortPanel{
multFactor.setText("1.0");
SNPanel = new ComfortPanel();
SNPanel.addAll(useSNRule,multFactor);
SNPanel.addAll(new JLabel(LocalizationManager.get("multFactor")),multFactor);
useSNRule.setSelected(true);
useSNRule.addActionListener(new ActionListener() {
......@@ -57,6 +60,7 @@ public class ReductionRulesChooser extends ComfortPanel{
useACRule,
useHERule,
usePDRRule,
useSNRule,
SNPanel
);
//By default all reduction rules should be applied
......
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial")
public class SolutionTab extends ComfortPanel {
private final JScrollPane scrollPane;
private final JLabel testLabel;
private final ComfortPanel scrollPaneContent;
private final JLabel clusterCount;
public SolutionTab() {
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
//init swing components
scrollPane = new JScrollPane();
testLabel = new JLabel("test");
this.addAll(scrollPane,testLabel);
scrollPaneContent = new ComfortPanel();
scrollPaneContent.setLayout(new BoxLayout(scrollPaneContent,BoxLayout.Y_AXIS));
scrollPane = new JScrollPane(scrollPaneContent);
scrollPane.setPreferredSize(new Dimension(150,400));
clusterCount = new JLabel("CLUSTERCOUNT");
this.addAll(clusterCount,scrollPane);
}
public ClusterView addCluster(long k) {
ClusterView clusterView = new ClusterView();
scrollPane.add(clusterView);
scrollPane.revalidate();
scrollPane.repaint();
scrollPaneContent.add(clusterView);
scrollPaneContent.add(Box.createVerticalStrut(8));
return clusterView;
}
public void setClusterNumber(long numberOfClusters) {
clusterCount.setText(LocalizationManager.get("clusterFound")+numberOfClusters);
}
}
......@@ -2,6 +2,7 @@ package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Component;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JTabbedPane;
......@@ -16,6 +17,7 @@ public class SolutionsPanel extends ComfortPanel implements CytoPanelComponent{
private JTabbedPane solutionTabs;
public SolutionsPanel() {
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
solutionTabs = new JTabbedPane();
this.add(solutionTabs);
}
......
......@@ -8,3 +8,8 @@ noLibTitle = Library not loaded!
noLibMessage = There is no Yoshiko Library currently loaded! You might have to specify its location.
cluster = Cluster
clusterSize = Cluster Size:
multFactor = Multiplicative Factor for SNR:
paidCost = Paid a total modification cost of:
clusterFound = Clusters found:
overrideSolution = Running Yoshiko will override previous solutions. Continue?
warning = Warning
\ No newline at end of file
......@@ -2,3 +2,4 @@ resultsPanelTitle = Yoshiko Ergebnisse
resolveLibPath = Yoshiko Library suchen
clusterSize = Cluster Gre:
solution = Lsung
clustersFound = Gefundene Cluster:
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment