diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/AlgorithmTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/AlgorithmTask.java index f63d9376f95758b45980e4562664091ca393119e..5502f2926c4074a95677f9a6817d064206cddedb 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/AlgorithmTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/AlgorithmTask.java @@ -8,6 +8,8 @@ import org.cytoscape.work.AbstractTask; import org.cytoscape.work.TaskMonitor; import org.slf4j.Logger; +import de.hhu.ba.yoshikoWrapper.gui.ClusterView; +import de.hhu.ba.yoshikoWrapper.gui.SolutionTab; import de.hhu.ba.yoshikoWrapper.gui.SolutionsPanel; import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; @@ -88,29 +90,41 @@ public class AlgorithmTask extends AbstractTask { SWIGTYPE_p_ysk__ClusterEditingSolutions solutions = LibraryInterface.processLibraryInput(input); taskMonitor.setProgress(0.9); + this.solutionsPanel.reset(); + long numberOfSolutions = LibraryInterface.ClusterEditingSolutions_getNumberOfSolutions(solutions); - this.solutionsPanel.erase(); - this.solutionsPanel.generateSolTabs(numberOfSolutions); - System.out.println("Found: "+numberOfSolutions+" solutions!"); + taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!"); + double modificationCost = LibraryInterface.ClusterEditingSolutions_getTotalCost(solutions); - System.out.println("Paid a total modification cost of: "+modificationCost); + taskMonitor.setStatusMessage("Paid a total modification cost of: "+modificationCost); + for (long i=0;i<numberOfSolutions;i++) { - System.out.println("Processing solution "+(i+1)+" of "+numberOfSolutions); + + taskMonitor.setStatusMessage("Processing solution "+(i+1)+" of "+numberOfSolutions); + + SolutionTab tab = this.solutionsPanel.addSolutionTab(i); String columnName = "YOSHIKO_SOLUTION_"+(i+1); + net.getDefaultNodeTable().deleteColumn(columnName); net.getDefaultNodeTable().createColumn(columnName, String.class, false); + long numberOfClusters = LibraryInterface.ClusterEditingSolutions_getNumberOfClusters(solutions, i); + for (long k=0;k<numberOfClusters;k++) { - System.out.println("Processing cluster "+(k+1)+" of "+numberOfClusters); + 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); long sizeOfCluster = LibraryInterface.IntVector_size(cluster); + cV.setClusterSize(sizeOfCluster); for (int l=0;l<sizeOfCluster;l++) { //Unsafe mismatch int long - System.out.println("Processing entry "+(l+1)+ " of "+sizeOfCluster); + taskMonitor.setStatusMessage("Processing entry "+(l+1)+ " of "+sizeOfCluster); int nodeID = LibraryInterface.IntVector_get(cluster, l); CyNode node = nodeMap.indexOf(nodeID); //<<< Another int/long conversion + cV.addNode(node); if (node == null) { - System.out.println("FATAL ERROR: Node was not previously mapped!"); + logger.error("FATAL ERROR: Node was not previously mapped!"); return; } net.getRow(node).set(columnName, ""+(k+1)); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java index fae2f2993e336257a039ddd2c56bed7e2a454134..ec76cf412ef6fafcd3507cb0d6f22c77fed6ce75 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/LocalizationManager.java @@ -22,7 +22,7 @@ public class LocalizationManager { static private ResourceBundle currentBundle; - static private Locale currentLanguage = usEnglish; + static private Locale currentLocale = usEnglish; static public Collection<Locale> getLocales(){ return locales.values(); @@ -30,27 +30,31 @@ public class LocalizationManager { static public String get(String key) { if (currentBundle == null) { - currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLanguage); + currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLocale); } return currentBundle.getString(key); } static public void switchLanguage(Locale lcl) { - currentLanguage = lcl; + currentLocale = lcl; updateBundle(); } public static void switchLanguage(String key) { System.out.println("DEBUG: SWITCHING TO: "+key); - currentLanguage = locales.get(key); + currentLocale = locales.get(key); updateBundle(); } private static void updateBundle() { - currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLanguage); + currentBundle = ResourceBundle.getBundle("YoshikoStrings",currentLocale); CyCore.cm.getProperties().setProperty( "locale", - currentLanguage.getLanguage()+currentLanguage.getCountry() + currentLocale.getLanguage()+currentLocale.getCountry() ); } + + public static Locale getCurrentLocale() { + return currentLocale; + } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ClusterView.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ClusterView.java new file mode 100644 index 0000000000000000000000000000000000000000..da5040ec3dcc14494fa8f49b807d3b087003f565 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ClusterView.java @@ -0,0 +1,42 @@ +package de.hhu.ba.yoshikoWrapper.gui; + +import javax.swing.BoxLayout; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.cytoscape.model.CyNode; + +import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; + +@SuppressWarnings("serial") +public class ClusterView extends ComfortPanel { + + private final JLabel title; + private final JLabel clusterSize; + + private JList<String> nodeList; + + public ClusterView() { + this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); + + this.title = new JLabel(); + this.clusterSize = new JLabel(); + this.nodeList = new JList<String>(); + + this.addAll(title,clusterSize,nodeList); + } + + public void setTitle(long x) { + this.title.setText(LocalizationManager.get("cluster")+" "+x); + } + + public void setClusterSize(long x) { + this.clusterSize.setText(LocalizationManager.get("clusterSize")+" "+x); + } + + public void addNode(CyNode node) { + this.nodeList.add(new JLabel(node.toString())); + revalidate(); + repaint(); + } +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcher.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcher.java index b017baebfa556c71d07ec91230a68d151094721d..3bed26beca14fc4fb421aa6d274bc66b2379b72e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcher.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcher.java @@ -15,6 +15,9 @@ public class LanguageSwitcher extends JComboBox<Locale>{ public LanguageSwitcher() { for (Locale l: LocalizationManager.getLocales() ) { this.addItem(l); + if (LocalizationManager.getCurrentLocale() == l) { + this.setSelectedItem(l); + } } this.addActionListener(new ActionListener() { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/SolutionTab.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/SolutionTab.java index 2a41d72e343ca3853b6b64baa6b82b5c8486f250..300a4f2e5bc0c068fb6f1cf1122df5491dbcb480 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/SolutionTab.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/SolutionTab.java @@ -1,7 +1,26 @@ package de.hhu.ba.yoshikoWrapper.gui; +import javax.swing.JLabel; +import javax.swing.JScrollPane; @SuppressWarnings("serial") public class SolutionTab extends ComfortPanel { + + private final JScrollPane scrollPane; + private final JLabel testLabel; + + public SolutionTab() { + //init swing components + scrollPane = new JScrollPane(); + testLabel = new JLabel("test"); + this.addAll(scrollPane,testLabel); + } + + + public ClusterView addCluster(long k) { + ClusterView clusterView = new ClusterView(); + scrollPane.add(clusterView); + return clusterView; + } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/SolutionsPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/SolutionsPanel.java index 425ed42249538fe4b641666c3ab6de5a8072e09d..a7ae442415071589c4d6c1a7473e8cda2d4b4f23 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/SolutionsPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/SolutionsPanel.java @@ -19,20 +19,18 @@ public class SolutionsPanel extends ComfortPanel implements CytoPanelComponent{ solutionTabs = new JTabbedPane(); this.add(solutionTabs); } - - public void generateSolTabs(long numberOfSolutions) { - for (long i=0;i<numberOfSolutions;i++) { - solutionTabs.add( - LocalizationManager.get("solution")+" "+(i+1), - new SolutionTab() - ); - } + + public SolutionTab addSolutionTab(long i) { + SolutionTab tab = new SolutionTab(); + solutionTabs.add( + LocalizationManager.get("solution")+" "+(i+1), + tab + ); + return tab; } - /** - * Helper pseudo-destructor as the object itself can't be reassigned due to Cytoscapes registry - */ - public void erase() { - this.removeAll(); + + public void reset() { + solutionTabs.removeAll(); } @Override diff --git a/src/main/resources/YoshikoStrings.properties b/src/main/resources/YoshikoStrings.properties index 44fedf8f0e73de02df992795f85c35a7dd2a3c32..3f25f4265be5f0d501c53be7a454a88e63bd0c1a 100644 --- a/src/main/resources/YoshikoStrings.properties +++ b/src/main/resources/YoshikoStrings.properties @@ -5,4 +5,6 @@ yoshTask = Performing Yoshiko Algorithm solution = Solution restartNeeded = Changes only take effect after restart! noLibTitle = Library not loaded! -noLibMessage = There is no Yoshiko Library currently loaded! You might have to specify its location. \ No newline at end of file +noLibMessage = There is no Yoshiko Library currently loaded! You might have to specify its location. +cluster = Cluster +clusterSize = Cluster Size: \ No newline at end of file diff --git a/src/main/resources/YoshikoStrings_de_DE.properties b/src/main/resources/YoshikoStrings_de_DE.properties index 079652eeda680d61bb20b9da5fce6708dc989494..57706bb2e5f532fae2a2fadbacf854a101dd2fe4 100644 --- a/src/main/resources/YoshikoStrings_de_DE.properties +++ b/src/main/resources/YoshikoStrings_de_DE.properties @@ -1,2 +1,4 @@ resultsPanelTitle = Yoshiko Ergebnisse -resolveLibPath = Yoshiko Library suchen \ No newline at end of file +resolveLibPath = Yoshiko Library suchen +clusterSize = Cluster Gr��e: +solution = L�sung \ No newline at end of file