diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoCluster.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoCluster.java index 7ad9b61f9d7300e41adf3cbeb2b8d908f0a1e81f..9f6289b6006f60c6211a95a602aaaebc9da26e4c 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoCluster.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoCluster.java @@ -38,10 +38,6 @@ import org.cytoscape.model.subnetwork.CySubNetwork; import org.cytoscape.view.layout.CyLayoutAlgorithm; import org.cytoscape.view.model.CyNetworkView; import org.cytoscape.view.presentation.RenderingEngine; -import org.cytoscape.work.FinishStatus; -import org.cytoscape.work.ObservableTask; -import org.cytoscape.work.TaskIterator; -import org.cytoscape.work.TaskObserver; import org.slf4j.Logger; import de.hhu.ba.yoshikoWrapper.core.CyCore; @@ -201,7 +197,4 @@ public class YoshikoCluster { } - - - } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterView.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterView.java index 573a1767cadddfb90496405fde813f70c9291a54..a60de61b2c981a8f237150a58b5b2a1355cc296e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterView.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ClusterView.java @@ -42,7 +42,6 @@ import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster; import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader; import de.hhu.ba.yoshikoWrapper.swing.SwingUtil; -import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask; @SuppressWarnings("serial") public class ClusterView extends JPanel { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/OperationModePanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/OperationModePanel.java index 6fa6d0ee625ec693de1430c0483a80a114f18aa3..bda3f6f4b5c69a8a640831aa076d23df28e04fef 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/OperationModePanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/OperationModePanel.java @@ -1,16 +1,16 @@ /******************************************************************************* * Copyright (C) 2017 Philipp Spohr - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -39,7 +39,7 @@ import javax.swing.GroupLayout.Alignment; @SuppressWarnings("serial") public class OperationModePanel extends JPanel{ - + //SWING COMPONENTS private final JRadioButton useHeuristic; private final JRadioButton useILP; @@ -48,36 +48,39 @@ public class OperationModePanel extends JPanel{ private final JCheckBox useTriangleCutsBox; private final JCheckBox usePartitionCutsBox; private final JCheckBox disableMultiThreading; - + private final ButtonGroup heuristicGroup; public OperationModePanel() { - + heuristicGroup = new ButtonGroup(); - useILP = new JRadioButton("Use Integer Linear Programming"); - useILP.setSelected(true); + useILP = new JRadioButton("Use Integer Linear Programming"); useHeuristic = new JRadioButton("Use Heuristic"); + + //As a default option we use the heuristic -> faster and usually good @Bachelor's Thesis //TODO: Save this as config? + useHeuristic.setSelected(true); + heuristicGroup.add(useILP); heuristicGroup.add(useHeuristic); - + solutionNumberChooser = new SolutionNumberChooser(); - + timeLimitSetter = new TimeLimitSetter(); - + useTriangleCutsBox = new JCheckBox("Use Triangle Cuts"); usePartitionCutsBox = new JCheckBox("Use Partition Cuts"); - + disableMultiThreading = new JCheckBox(LocalizationManager.get("disableMultiThreading")); disableMultiThreading.setSelected(true); - + //Link time limit option to ILP useILP.addActionListener(ilpHeuristicSwitch); useHeuristic.addActionListener(ilpHeuristicSwitch); SwingUtil.addAll(this, - useILP, useHeuristic, + useILP, solutionNumberChooser, timeLimitSetter, useTriangleCutsBox, @@ -85,55 +88,62 @@ public class OperationModePanel extends JPanel{ disableMultiThreading ); + //We set all components to enabled/disabled according to mode + ilpHeuristicSwitch(); + //Layout GroupLayout layout = new GroupLayout(this); - + layout.setAutoCreateContainerGaps(true); - + layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true) - .addComponent(useILP, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(useHeuristic, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useILP, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(solutionNumberChooser, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(timeLimitSetter, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(useTriangleCutsBox, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(usePartitionCutsBox, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(disableMultiThreading, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) ); - + layout.setVerticalGroup(layout.createSequentialGroup() - .addComponent(useILP) .addComponent(useHeuristic) + .addComponent(useILP) .addComponent(solutionNumberChooser) .addComponent(timeLimitSetter) .addComponent(useTriangleCutsBox) .addComponent(usePartitionCutsBox) .addComponent(disableMultiThreading) ); - + this.setLayout(layout); - + + } + + private void ilpHeuristicSwitch() { + if (useILP.isSelected()) { + timeLimitSetter.setEnabled(true); + useTriangleCutsBox.setEnabled(true); + usePartitionCutsBox.setEnabled(true); + solutionNumberChooser.setEnabled(true); + disableMultiThreading.setEnabled(true); + } + else { + timeLimitSetter.setEnabled(false); + useTriangleCutsBox.setEnabled(false); + usePartitionCutsBox.setEnabled(false); + solutionNumberChooser.setEnabled(false); + disableMultiThreading.setEnabled(false); + } } - + ActionListener ilpHeuristicSwitch = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if (useILP.isSelected()) { - timeLimitSetter.setEnabled(true); - useTriangleCutsBox.setEnabled(true); - usePartitionCutsBox.setEnabled(true); - solutionNumberChooser.setEnabled(true); - disableMultiThreading.setEnabled(true); - } - else { - timeLimitSetter.setEnabled(false); - useTriangleCutsBox.setEnabled(false); - usePartitionCutsBox.setEnabled(false); - solutionNumberChooser.setEnabled(false); - disableMultiThreading.setEnabled(false); - } - } + ilpHeuristicSwitch(); + } }; - + //SETTER GETTER public int getTimeLimit() { @@ -151,7 +161,7 @@ public class OperationModePanel extends JPanel{ public boolean useHeuristic() { return useHeuristic.isSelected(); } - + public boolean isMultiThreadingDisabled() { return disableMultiThreading.isSelected(); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java index 99c559ec934807e8ce3bf5d4381e334e39aec8a2..a7a93cbda255e5c032af9198cc6221e1b1d4b8d2 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java @@ -25,7 +25,6 @@ import static javax.swing.GroupLayout.*; import java.awt.Color; import java.awt.Component; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java index 91a9c8677646afd7ca98c9d200e9e795d35a8be7..e698fb2f39404732fca7dbb7666d61d02ed7d342 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/SolutionTab.java @@ -22,9 +22,9 @@ package de.hhu.ba.yoshikoWrapper.swing.components; import static javax.swing.GroupLayout.DEFAULT_SIZE; - import static javax.swing.GroupLayout.PREFERRED_SIZE; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -41,18 +41,15 @@ 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; @@ -116,11 +113,15 @@ public class SolutionTab extends JPanel { //Declaration of Swing Components clusterViewList = new ClusterViewList(); + //Build CV list for (YoshikoCluster c: solution.clusters) { ClusterView clusterView = new ClusterView(c); clusterViewList.add(clusterView); } + //Apply default visibility (Hide singles) + clusterViewList.toggleSingleVisibility(false); + scrollPane = new JScrollPane(clusterViewList); clusterCount = new JLabel(LocalizationManager.get("clusterFound")+" "+s.clusters.size()); @@ -200,12 +201,12 @@ public class SolutionTab extends JPanel { 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) + .addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,Short.MAX_VALUE) + .addComponent(hideSingles,DEFAULT_SIZE,DEFAULT_SIZE,Short.MAX_VALUE) .addGap(8) - .addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,Short.MAX_VALUE) - .addComponent(createClusterView,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) - .addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) + .addComponent(scrollPane,PREFERRED_SIZE,PREFERRED_SIZE,Short.MAX_VALUE) + .addComponent(createClusterView,DEFAULT_SIZE,DEFAULT_SIZE,Short.MAX_VALUE) + .addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,Short.MAX_VALUE) ); layout.setVerticalGroup(layout.createSequentialGroup() .addGap(8) diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java index 80bc8ae8049c5af37f7acf8d45d79d9e2ac2159b..c7e2a583e758d986056a7c5d3a28066cf79e15d8 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java @@ -225,6 +225,7 @@ public class AlgorithmTask extends AbstractTask { eastPanel.setSelectedIndex(eastPanel.indexOfComponent(resultPanel)); //Show (might be invisible) eastPanel.setState(CytoPanelState.DOCK); + //eastPanel.getThisComponent().revalidate(); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java index a82a9802e07b1d4417c01d26758edc1f5a9c4c80..18a7ef2c43abdd207719515269c18d4a33adb274 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/CreateMetaGraphTask.java @@ -3,8 +3,6 @@ package de.hhu.ba.yoshikoWrapper.tasks; import java.util.ArrayList; import java.util.HashMap; -import javax.swing.SwingUtilities; - import org.cytoscape.model.CyEdge; import org.cytoscape.model.CyNetwork; import org.cytoscape.model.CyNode; @@ -13,11 +11,7 @@ import org.cytoscape.model.subnetwork.CySubNetwork; import org.cytoscape.view.layout.CyLayoutAlgorithm; import org.cytoscape.view.model.CyNetworkView; import org.cytoscape.work.AbstractTask; -import org.cytoscape.work.FinishStatus; -import org.cytoscape.work.ObservableTask; -import org.cytoscape.work.Task; import org.cytoscape.work.TaskMonitor; -import org.cytoscape.work.TaskObserver; import de.hhu.ba.yoshikoWrapper.core.CyCore; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;