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; ...@@ -15,7 +15,6 @@ import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; 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_std__vectorT_int_t;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_yskInput__LibraryInput; 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 { public class AlgorithmTask extends AbstractTask {
...@@ -101,7 +100,7 @@ public class AlgorithmTask extends AbstractTask { ...@@ -101,7 +100,7 @@ public class AlgorithmTask extends AbstractTask {
LibraryInterface.LibraryInput_setDefaultInsertionCost(input, insertionCostDefault); LibraryInterface.LibraryInput_setDefaultInsertionCost(input, insertionCostDefault);
//Call Yoshiko <<< Algorithm is performed here //Call Yoshiko <<< Algorithm is performed here
SWIGTYPE_p_ysk__ClusterEditingSolutions solutions = LibraryInterface.processLibraryInput( CyCore.currentSolutions = LibraryInterface.processLibraryInput(
input, input,
1, 1,
bitMaskRules, bitMaskRules,
...@@ -115,11 +114,11 @@ public class AlgorithmTask extends AbstractTask { ...@@ -115,11 +114,11 @@ public class AlgorithmTask extends AbstractTask {
this.solutionsPanel.reset(); this.solutionsPanel.reset();
long numberOfSolutions = LibraryInterface.ClusterEditingSolutions_getNumberOfSolutions(solutions); long numberOfSolutions = LibraryInterface.ClusterEditingSolutions_getNumberOfSolutions(CyCore.currentSolutions);
taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!"); taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!");
double modificationCost = LibraryInterface.ClusterEditingSolutions_getTotalCost(solutions); double modificationCost = LibraryInterface.ClusterEditingSolutions_getTotalCost(CyCore.currentSolutions);
taskMonitor.setStatusMessage("Paid a total modification cost of: "+modificationCost); taskMonitor.setStatusMessage(LocalizationManager.get("paidCost")+modificationCost);
for (long i=0;i<numberOfSolutions;i++) { for (long i=0;i<numberOfSolutions;i++) {
...@@ -131,13 +130,14 @@ public class AlgorithmTask extends AbstractTask { ...@@ -131,13 +130,14 @@ public class AlgorithmTask extends AbstractTask {
net.getDefaultNodeTable().deleteColumn(columnName); net.getDefaultNodeTable().deleteColumn(columnName);
net.getDefaultNodeTable().createColumn(columnName, String.class, false); 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++) { for (long k=0;k<numberOfClusters;k++) {
ClusterView cV = tab.addCluster(k); ClusterView cV = tab.addCluster(k);
cV.setTitle((k+1)); cV.setTitle((k+1));
taskMonitor.setStatusMessage("Processing cluster "+(k+1)+" of "+numberOfClusters); 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); long sizeOfCluster = LibraryInterface.IntVector_size(cluster);
cV.setClusterSize(sizeOfCluster); cV.setClusterSize(sizeOfCluster);
for (int l=0;l<sizeOfCluster;l++) { //Unsafe mismatch int long for (int l=0;l<sizeOfCluster;l++) { //Unsafe mismatch int long
...@@ -154,9 +154,6 @@ public class AlgorithmTask extends AbstractTask { ...@@ -154,9 +154,6 @@ public class AlgorithmTask extends AbstractTask {
} }
} }
solutionsPanel.revalidate();
solutionsPanel.repaint();
LibraryInterface.delete_LibraryInput(input); LibraryInterface.delete_LibraryInput(input);
taskMonitor.setProgress(1.0); taskMonitor.setProgress(1.0);
} }
......
...@@ -3,8 +3,11 @@ package de.hhu.ba.yoshikoWrapper.core; ...@@ -3,8 +3,11 @@ package de.hhu.ba.yoshikoWrapper.core;
import org.cytoscape.application.CyApplicationManager; import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.work.swing.DialogTaskManager; import org.cytoscape.work.swing.DialogTaskManager;
import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_ysk__ClusterEditingSolutions;
public class CyCore { public class CyCore {
public static CyApplicationManager cy; public static CyApplicationManager cy;
public static DialogTaskManager dialogTaskManager; public static DialogTaskManager dialogTaskManager;
public static ConfigurationManager cm; public static ConfigurationManager cm;
public static SWIGTYPE_p_ysk__ClusterEditingSolutions currentSolutions;
} }
package de.hhu.ba.yoshikoWrapper.gui; 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.BoxLayout;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.border.Border;
import org.cytoscape.model.CyNode; import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyRow;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial") @SuppressWarnings("serial")
...@@ -14,33 +24,87 @@ public class ClusterView extends ComfortPanel { ...@@ -14,33 +24,87 @@ public class ClusterView extends ComfortPanel {
private final JLabel title; private final JLabel title;
private final JLabel clusterSize; 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() { public ClusterView() {
//Swing init
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
this.title = new JLabel("CLUSTERTITLE"); title = new JLabel("CLUSTERTITLE");
this.clusterSize = new JLabel("CLUSTERLABEL"); clusterSize = new JLabel("CLUSTERLABEL");
this.nodeList = new JList<String>();
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) { public void setTitle(long x) {
this.title.setText(LocalizationManager.get("cluster")+" "+x); this.title.setText(LocalizationManager.get("cluster")+" "+x);
revalidate();
repaint();
} }
public void setClusterSize(long x) { public void setClusterSize(long x) {
this.clusterSize.setText(LocalizationManager.get("clusterSize")+" "+x); this.clusterSize.setText(LocalizationManager.get("clusterSize")+" "+x);
revalidate();
repaint();
} }
public void addNode(CyNode node) {
this.nodeList.add(new JLabel(node.toString()));
revalidate(); private MouseListener mouseListener = new MouseListener() {
repaint();
@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; ...@@ -21,6 +21,7 @@ import de.hhu.ba.yoshikoWrapper.core.AlgorithmTask;
import de.hhu.ba.yoshikoWrapper.core.CyCore; import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; 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 /**This class describes the Swing Panel that the user interacts with in cytoscape
* @author Philipp Spohr, Aug 6, 2017 * @author Philipp Spohr, Aug 6, 2017
...@@ -85,12 +86,48 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent { ...@@ -85,12 +86,48 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
JButton runButton = new JButton("RUN"); 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 @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (YoshikoLoader.isLibraryLoaded()){ 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( AbstractTask yoshiko = new AlgorithmTask(
CyCore.cy.getCurrentNetwork(), CyCore.cy.getCurrentNetwork(),
timeLimitSetter.getTimeLimit(), timeLimitSetter.getTimeLimit(),
...@@ -118,26 +155,7 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent { ...@@ -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 //GETTER / SETTER
...@@ -146,7 +164,6 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent { ...@@ -146,7 +164,6 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
return this; return this;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.cytoscape.application.swing.CytoPanelComponent#getCytoPanelName() * @see org.cytoscape.application.swing.CytoPanelComponent#getCytoPanelName()
*/ */
......
...@@ -6,6 +6,9 @@ import java.awt.event.ActionListener; ...@@ -6,6 +6,9 @@ import java.awt.event.ActionListener;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JLabel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ReductionRulesChooser extends ComfortPanel{ public class ReductionRulesChooser extends ComfortPanel{
...@@ -35,7 +38,7 @@ public class ReductionRulesChooser extends ComfortPanel{ ...@@ -35,7 +38,7 @@ public class ReductionRulesChooser extends ComfortPanel{
multFactor.setText("1.0"); multFactor.setText("1.0");
SNPanel = new ComfortPanel(); SNPanel = new ComfortPanel();
SNPanel.addAll(useSNRule,multFactor); SNPanel.addAll(new JLabel(LocalizationManager.get("multFactor")),multFactor);
useSNRule.setSelected(true); useSNRule.setSelected(true);
useSNRule.addActionListener(new ActionListener() { useSNRule.addActionListener(new ActionListener() {
...@@ -57,6 +60,7 @@ public class ReductionRulesChooser extends ComfortPanel{ ...@@ -57,6 +60,7 @@ public class ReductionRulesChooser extends ComfortPanel{
useACRule, useACRule,
useHERule, useHERule,
usePDRRule, usePDRRule,
useSNRule,
SNPanel SNPanel
); );
//By default all reduction rules should be applied //By default all reduction rules should be applied
......
package de.hhu.ba.yoshikoWrapper.gui; package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class SolutionTab extends ComfortPanel { public class SolutionTab extends ComfortPanel {
private final JScrollPane scrollPane; private final JScrollPane scrollPane;
private final JLabel testLabel; private final ComfortPanel scrollPaneContent;
private final JLabel clusterCount;
public SolutionTab() { public SolutionTab() {
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
//init swing components //init swing components
scrollPane = new JScrollPane(); scrollPaneContent = new ComfortPanel();
testLabel = new JLabel("test"); scrollPaneContent.setLayout(new BoxLayout(scrollPaneContent,BoxLayout.Y_AXIS));
this.addAll(scrollPane,testLabel); scrollPane = new JScrollPane(scrollPaneContent);
scrollPane.setPreferredSize(new Dimension(150,400));
clusterCount = new JLabel("CLUSTERCOUNT");
this.addAll(clusterCount,scrollPane);
} }
public ClusterView addCluster(long k) { public ClusterView addCluster(long k) {
ClusterView clusterView = new ClusterView(); ClusterView clusterView = new ClusterView();
scrollPane.add(clusterView); scrollPaneContent.add(clusterView);
scrollPane.revalidate(); scrollPaneContent.add(Box.createVerticalStrut(8));
scrollPane.repaint();
return clusterView; return clusterView;
} }
public void setClusterNumber(long numberOfClusters) {
clusterCount.setText(LocalizationManager.get("clusterFound")+numberOfClusters);
}
} }
...@@ -2,6 +2,7 @@ package de.hhu.ba.yoshikoWrapper.gui; ...@@ -2,6 +2,7 @@ package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Component; import java.awt.Component;
import javax.swing.BoxLayout;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JTabbedPane; import javax.swing.JTabbedPane;
...@@ -16,6 +17,7 @@ public class SolutionsPanel extends ComfortPanel implements CytoPanelComponent{ ...@@ -16,6 +17,7 @@ public class SolutionsPanel extends ComfortPanel implements CytoPanelComponent{
private JTabbedPane solutionTabs; private JTabbedPane solutionTabs;
public SolutionsPanel() { public SolutionsPanel() {
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
solutionTabs = new JTabbedPane(); solutionTabs = new JTabbedPane();
this.add(solutionTabs); this.add(solutionTabs);
} }
......
...@@ -8,3 +8,8 @@ noLibTitle = Library not loaded! ...@@ -8,3 +8,8 @@ noLibTitle = Library not loaded!
noLibMessage = There is no Yoshiko Library currently loaded! You might have to specify its location. noLibMessage = There is no Yoshiko Library currently loaded! You might have to specify its location.
cluster = Cluster cluster = Cluster
clusterSize = Cluster Size: 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 ...@@ -2,3 +2,4 @@ resultsPanelTitle = Yoshiko Ergebnisse
resolveLibPath = Yoshiko Library suchen resolveLibPath = Yoshiko Library suchen
clusterSize = Cluster Gre: clusterSize = Cluster Gre:
solution = Lsung 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