Commit b2b1c705 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Added support for hiding single node clusters

parent 7e53598d
......@@ -61,7 +61,6 @@ public class YoshikoLoader {
//This might happen as Java doesn't unload native libs
//One such case might be reloading the Cytoscape app on-the-fly
logger.error(e.getMessage());
return;
}
LibraryInterface.setVerbosity(3);
//update cfg
......
......@@ -74,4 +74,16 @@ public class ClusterViewList extends JPanel implements Scrollable {
return ret;
}
public void toggleSingleVisibility(boolean showSingles) {
for (ClusterView cv : getClusterViews()) {
if (cv.getCluster().getSize() > 1 || showSingles) {
cv.setVisible(true);
}
else {
cv.setVisible(false);
}
}
}
}
......@@ -19,26 +19,21 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.swing;
package de.hhu.ba.yoshikoWrapper.swing.components;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import org.cytoscape.util.swing.BasicCollapsiblePanel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.swing.components.LanguageSwitcher;
import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
@SuppressWarnings("serial")
public class LanguageSwitcherPanel extends BasicCollapsiblePanel{
public class LanguageSwitcherPanel extends JPanel{
final private LanguageSwitcher switcher;
public LanguageSwitcherPanel() {
super(LocalizationManager.get("switchLanguage"));
final LanguageSwitcher switcher;
//final BasicCollapsiblePanel ret = new BasicCollapsiblePanel();
//getContentPane().setLayout(new BoxLayout(getContentPane(),BoxLayout.X_AXIS));
//SWING COMPONENTS INIT
switcher = new LanguageSwitcher();
SwingUtil.addAll(this,
......
......@@ -61,7 +61,6 @@ import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.cytoUtil.GraphAnalyzer;
import de.hhu.ba.yoshikoWrapper.swing.AboutDialogFactory;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.swing.LanguageSwitcherPanel;
import de.hhu.ba.yoshikoWrapper.swing.LibraryPanelFactory;
import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask;
......@@ -74,18 +73,23 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
//SWING COMPONENTS
private final YoshikoHeader header;
private final JButton about;
private final JCheckBox showAdvancedOptions;
private final ArrayList<JComponent> advancedOptions;
private final JScrollPane scrollPane;
private final JPanel scrollableContent;
//Those two work with factories whysoever
private final BasicCollapsiblePanel langPanel;
/**
* Panel for selecting the application language
*/
private final LanguageSwitcherPanel langPanel;
private final BasicCollapsiblePanel langWrapper;
private final BasicCollapsiblePanel libraryPanel;
//Those don't work really as collapsible panels and cause glitches which forces the workaround of wrapping them
......@@ -128,6 +132,8 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
scrollPane.setBorder(BorderFactory.createEmptyBorder());
langPanel = new LanguageSwitcherPanel();
langWrapper = new BasicCollapsiblePanel(LocalizationManager.get("switchLanguage"));
langWrapper.add(langPanel);
libraryPanel = LibraryPanelFactory.createLibraryPanel();
//If no library is loaded yet the obvious panel should be showing up
......@@ -151,15 +157,16 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
runButton = new JButton(LocalizationManager.get("run"));
runButton.addActionListener(buttonListener);
//Add components to main panel
//Add components to the scrollable part of the main panel
SwingUtil.addAll(scrollableContent,
langPanel,
langWrapper,
libraryPanel,
ecPanelWrapper,
reductionWrapper,
opWrapper
);
//Add the 'fixed' components to the main panel
SwingUtil.addAll(this,
header,
about,
......@@ -207,7 +214,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
);
scrollLayout.setHorizontalGroup(scrollLayout.createParallelGroup(Alignment.LEADING,true)
.addComponent(langPanel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(langWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(libraryPanel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
......@@ -226,7 +233,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
);
scrollLayout.setVerticalGroup(scrollLayout.createSequentialGroup()
.addComponent(langPanel,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(langWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(libraryPanel,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
......
......@@ -27,24 +27,32 @@ import static javax.swing.GroupLayout.PREFERRED_SIZE;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.Group;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.cytoscape.work.TaskIterator;
import com.sun.media.jfxmedia.logging.Logger;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution;
import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
import de.hhu.ba.yoshikoWrapper.tasks.CreateClusterViews;
import de.hhu.ba.yoshikoWrapper.tasks.CreateMetaGraphTask;
......@@ -56,10 +64,10 @@ import de.hhu.ba.yoshikoWrapper.tasks.CreateMetaGraphTask;
public class SolutionTab extends JPanel {
//SWING COMPONENTS
private final JLabel clusterCount;
private final JCheckBox hideSingles;
private final JScrollPane scrollPane;
private final ClusterViewList clusterViewList;
private final JLabel clusterCount;
private final JButton createClusterView;
private final JButton createMetaGraph;
......@@ -83,6 +91,28 @@ public class SolutionTab extends JPanel {
//Save abstract solution object for reference
this.solution = s;
hideSingles = new JCheckBox(LocalizationManager.get("hideSingles"));
//We check this option as default //TODO: We might save that to config?
hideSingles.setSelected(true);
hideSingles.addItemListener(new ItemListener(){
@Override
public void itemStateChanged(ItemEvent e) {
try {
if(e.getStateChange() == ItemEvent.SELECTED) {
clusterViewList.toggleSingleVisibility(false);
}
else if (e.getStateChange() == ItemEvent.DESELECTED) {
clusterViewList.toggleSingleVisibility(true);
}
}
catch(Exception ex) { //TODO: Specify which type of exceptions can actually occur and process accordingly
ex.printStackTrace();
}
}
});
//Declaration of Swing Components
clusterViewList = new ClusterViewList();
......@@ -164,11 +194,14 @@ public class SolutionTab extends JPanel {
clusterViewList.setLayout(scrollLayout);
//Define main layout for solution tab
layout = new GroupLayout(this);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER,true)
.addGap(8)
.addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(hideSingles,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addGap(8)
.addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,Short.MAX_VALUE)
.addComponent(createClusterView,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
......@@ -177,6 +210,7 @@ public class SolutionTab extends JPanel {
layout.setVerticalGroup(layout.createSequentialGroup()
.addGap(8)
.addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(hideSingles,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addGap(8)
.addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(createClusterView,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
......
......@@ -45,6 +45,7 @@ exportSelectedClusters = Export selected clusters
firstStart = Thanks for using the Yoshiko Clustering Tool!\nIt appears, that this is your first time using this tool.\nIf you want an in-depth explanation of the algorithm please refer to: [INSERT COOL LINK HERE]
gap = Gap
getYoshiko = Get Yoshiko Library
hideSingles = Hide single-node clusters
icTooltip = This value is used to determine what the algorithm pays when inserting an edge.\nExisting mappings overwrite this value.\nA higher value means that the algorithm is less likely to insert edges in order to generate a cluster.
incompleteResult = This run yielded no usable result!
instance = Instance
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment