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

Swing is everything but fun

parent 489d3f9f
Branches
Tags
No related merge requests found
Showing
with 517 additions and 133 deletions
package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.JComponent;
import javax.swing.JPanel;
/**
* Custom extension of the standard JPanel that provides some comfort functions
*
*/
@SuppressWarnings("serial")
public class ComfortPanel extends JPanel {
/**
* Comfort Function
* @param components The components that are to be added to this panel
*/
protected void addAll(JComponent... components) {
for (JComponent c : components){
this.add(c);
}
}
}
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.JFormattedTextField;
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.JPanel;
import org.cytoscape.model.CyColumn;
import org.cytoscape.util.swing.BasicCollapsiblePanel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial") //Will never be serialized
public class EditCostPanel extends ComfortPanel {
public class EditCostPanel extends BasicCollapsiblePanel {
//SWING COMPONENTS
private ColumnMapper columnMapper;
......@@ -24,10 +44,11 @@ public class EditCostPanel extends ComfortPanel {
private JLabel icLabel;
private JLabel dcLabel;
private ComfortPanel groupIC;
private ComfortPanel groupDC;
private JPanel groupIC;
private JPanel groupDC;
public EditCostPanel() {
super(LocalizationManager.get("editingCostPanel"));
//Define Layout
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
//Initialize components
......@@ -43,22 +64,20 @@ public class EditCostPanel extends ComfortPanel {
icLabel = new JLabel(LocalizationManager.get("defaultInsertion"));
dcLabel = new JLabel(LocalizationManager.get("defaultDeletion"));
//Group the labels with their text fields
groupIC = new ComfortPanel();
groupDC = new ComfortPanel();
groupIC = new JPanel();
groupDC = new JPanel();
groupIC.setLayout(new FlowLayout());
groupDC.setLayout(new FlowLayout());
groupIC.addAll(icLabel,icField);
groupDC.addAll(dcLabel,dcField);
SwingUtil.addAll(groupIC,icLabel,icField);
SwingUtil.addAll(groupDC,dcLabel,dcField);
this.addAll(columnMapper,groupIC,groupDC);
SwingUtil.addAll(this,columnMapper,groupIC,groupDC);
//Decoration/Visual
Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
border = BorderFactory.createTitledBorder(border,LocalizationManager.get("editingCostPanel"));
this.setBorder(border);
//Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
//this.setBorder(border);
}
//SETTER / GETTER
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.text.DecimalFormat;
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.JFormattedTextField;
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Color;
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
......@@ -10,12 +31,14 @@ import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.border.EtchedBorder;
import org.cytoscape.util.swing.BasicCollapsiblePanel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
@SuppressWarnings("serial")
public class LibraryPanel extends ComfortPanel {
public class LibraryPanel extends ComfortCollapsiblePanel {
//SYMBOLIC LINKS
private LibraryPanel self = this;
......@@ -26,6 +49,7 @@ public class LibraryPanel extends ComfortPanel {
public LibraryPanel() {
super(LocalizationManager.get("libraryPanel"));
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
//SWING COMPONENT INITIALIZATION
libStatusPanel = new LibStatusPanel();
......@@ -54,9 +78,7 @@ public class LibraryPanel extends ComfortPanel {
}
});
this.addAll(libStatusPanel,yoshikoVersionLabel,searchLibButton);
SwingUtil.addAll(this,libStatusPanel,yoshikoVersionLabel,searchLibButton);
//Decoration/Visual
this.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
}
}
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import javax.swing.BoxLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
......@@ -26,11 +52,10 @@ import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
/**This class describes the Swing Panel that the user interacts with in cytoscape
* @author Philipp Spohr, Aug 6, 2017
*
*/
@SuppressWarnings("serial")
public class MainPanel extends ComfortPanel implements CytoPanelComponent {
public class MainPanel extends JPanel implements CytoPanelComponent {
//SWING COMPONENTS
......@@ -40,22 +65,15 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
* Swing is a bit special sometimes, so a panel is used to wrap the lang-switcher.
* This prevents stretching of the component
*/
private final ComfortPanel langSwitcherWrapper;
private final JPanel langSwitcherWrapper;
private final LanguageSwitcher langSwitcher;
private final LibraryPanel libraryPanel;
private final EditCostPanel ecPanel;
private final ReductionRulesChooser reductionRulesChooser;
private final OperationModePanel opModePanel;
private final JCheckBox showAdvancedOptions;
//OTHER
private final ArrayList<JComponent> advancedOptions;
/**
* Main constructor, creates a new Panel and initializes subcomponents
......@@ -63,35 +81,36 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
public MainPanel() {
//SWING INIT
this.setLayout(new FlowLayout());
//Initialize Swing components
header = new YoshikoHeader();
langSwitcherWrapper = new ComfortPanel();
langSwitcherWrapper = new JPanel();
langSwitcher = new LanguageSwitcher();
langSwitcherWrapper.addAll(new JLabel(LocalizationManager.get("switchLanguage")),langSwitcher);
langSwitcherWrapper.add(new JLabel(LocalizationManager.get("switchLanguage")));
langSwitcherWrapper.add(langSwitcher);
langSwitcherWrapper.setLayout(new FlowLayout());
libraryPanel = new LibraryPanel();
if (!YoshikoLoader.isLibraryLoaded()) {
libraryPanel.setCollapsed(false);
}
ecPanel = new EditCostPanel();
ecPanel.setCollapsed(false);
opModePanel = new OperationModePanel();
reductionRulesChooser = new ReductionRulesChooser();
JButton runButton = new JButton("RUN");
JButton runButton = new JButton(LocalizationManager.get("run"));
runButton.addActionListener(buttonListener);
showAdvancedOptions = new JCheckBox(LocalizationManager.get("showAdvanced"));
showAdvancedOptions.addActionListener(toggleAdvancedOptionsListener);
this.addAll(
SwingUtil.addAll(this,
header,
langSwitcherWrapper,
showAdvancedOptions,
libraryPanel,
ecPanel,
reductionRulesChooser,
......@@ -99,33 +118,33 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
runButton
);
advancedOptions = new ArrayList<JComponent>();
//Manage all advanced components separately to enable toggling
advancedOptions.addAll(
Arrays.asList(
opModePanel,
reductionRulesChooser
)
);
showAdvancedOptions(false);
this.setVisible(true);
}
//Layout
GroupLayout layout = new GroupLayout(this);
private ActionListener toggleAdvancedOptionsListener = new ActionListener() {
layout.setHorizontalGroup(layout.createParallelGroup()
.addComponent(header)
.addComponent(langSwitcherWrapper)
.addComponent(libraryPanel)
.addComponent(ecPanel)
.addComponent(reductionRulesChooser)
.addComponent(opModePanel)
.addComponent(runButton)
);
@Override
public void actionPerformed(ActionEvent e) {
showAdvancedOptions(showAdvancedOptions.isSelected());
}
layout.setVerticalGroup(layout.createSequentialGroup()
.addComponent(header)
.addComponent(langSwitcherWrapper)
.addComponent(libraryPanel)
.addComponent(ecPanel)
.addComponent(reductionRulesChooser)
.addComponent(opModePanel)
.addComponent(runButton)
);
};
this.setLayout(layout);
private void showAdvancedOptions(boolean show) {
for (JComponent j : advancedOptions) {
j.setVisible(show);
}
this.setVisible(true);
}
/**
......@@ -191,7 +210,7 @@ public class MainPanel extends ComfortPanel implements CytoPanelComponent {
}
public Icon getIcon() {
return GraphicsLoader.getLogo();
return GraphicsLoader.getLogo(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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
......@@ -11,10 +32,12 @@ import javax.swing.JRadioButton;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import org.cytoscape.util.swing.BasicCollapsiblePanel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial")
public class OperationModePanel extends ComfortPanel{
public class OperationModePanel extends ComfortCollapsiblePanel{
private final JRadioButton useHeuristic;
private final JRadioButton useILP;
private final TimeLimitSetter timeLimitSetter;
......@@ -25,7 +48,7 @@ public class OperationModePanel extends ComfortPanel{
private final ButtonGroup heuristicGroup;
public OperationModePanel() {
super(LocalizationManager.get("operationMode"));
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
heuristicGroup = new ButtonGroup();
......@@ -49,11 +72,8 @@ public class OperationModePanel extends ComfortPanel{
useHeuristic.addActionListener(ilpHeuristicSwitch);
this.addAll(useILP,useHeuristic,solutionNumberChooser,timeLimitSetter,useTriangleCutsBox,usePartitionCutsBox);
SwingUtil.addAll(this,useILP,useHeuristic,solutionNumberChooser,timeLimitSetter,useTriangleCutsBox,usePartitionCutsBox);
Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
border = BorderFactory.createTitledBorder(border,LocalizationManager.get("operationMode"));
this.setBorder(border);
}
ActionListener ilpHeuristicSwitch = new ActionListener() {
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.JPanel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial")
public class ReductionRulesChooser extends ComfortPanel{
public class ReductionRulesChooser extends ComfortCollapsiblePanel{
private final JCheckBox useCRule;
private final JCheckBox useCCRule;
......@@ -25,10 +44,11 @@ public class ReductionRulesChooser extends ComfortPanel{
private final DoubleInputField multFactor;
private final ComfortPanel SNPanel;
private final JPanel SNPanel;
public ReductionRulesChooser() {
super(LocalizationManager.get("redRuleChooserTitle"));
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
//Initialize subcomponents
useCRule = new JCheckBox("Use Clique Rule");
......@@ -39,10 +59,16 @@ public class ReductionRulesChooser extends ComfortPanel{
useSNRule = new JCheckBox("Use Similar Neighborhood Rule");
multFactor = new DoubleInputField(1, Double.POSITIVE_INFINITY);
multFactor.setText("1.0");
SNPanel = new ComfortPanel();
SNPanel = new JPanel();
SwingUtil.addAll(SNPanel,new JLabel(LocalizationManager.get("multFactor")),multFactor);
SNPanel.addAll(new JLabel(LocalizationManager.get("multFactor")),multFactor);
useSNRule.setSelected(true);
useCRule.setSelected(true);
useCCRule.setSelected(true);
useACRule.setSelected(true);
useHERule.setSelected(true);
usePDRRule.setSelected(true);
useSNRule.addActionListener(new ActionListener() {
@Override
......@@ -57,7 +83,7 @@ public class ReductionRulesChooser extends ComfortPanel{
});
this.addAll(
SwingUtil.addAll(this,
useCRule,
useCCRule,
useACRule,
......@@ -66,16 +92,6 @@ public class ReductionRulesChooser extends ComfortPanel{
useSNRule,
SNPanel
);
//By default all reduction rules should be applied
for (Component c :this.getComponents()) {
if (c instanceof JCheckBox) {
((JCheckBox)c).setSelected(true);
}
}
//Create titled border
Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
this.setBorder(BorderFactory.createTitledBorder(border, LocalizationManager.get("redRuleChooserTitle")));
}
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Component;
......@@ -9,12 +30,14 @@ import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelName;
import de.hhu.ba.yoshikoWrapper.core.CyCore;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution;
......@@ -23,7 +46,7 @@ import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution;
* Conforms to CY 3.5 by being a CytoPanelComponent which is the norm for "result" panels
*/
@SuppressWarnings("serial")//Will never be serialized
public class ResultPanel extends ComfortPanel implements CytoPanelComponent{
public class ResultPanel extends JPanel implements CytoPanelComponent{
private final JTabbedPane solutionTabs;
private final JLabel costLabel;
......@@ -56,7 +79,7 @@ public class ResultPanel extends ComfortPanel implements CytoPanelComponent{
});
addAll(costLabel,solutionTabs,destroyButton);
SwingUtil.addAll(this,costLabel,solutionTabs,destroyButton);
}
public void deleteSolution() {
......@@ -106,8 +129,7 @@ public class ResultPanel extends ComfortPanel implements CytoPanelComponent{
@Override
public Icon getIcon() {
// TODO Auto-generated method stub
return null;
return GraphicsLoader.getLogo(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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial")
public class SolutionNumberChooser extends ComfortPanel {
public class SolutionNumberChooser extends JPanel {
private final JSpinner numSolutionsSetter;
private final JLabel label;
......@@ -16,7 +38,7 @@ public class SolutionNumberChooser extends ComfortPanel {
numSolutionsSetter = new JSpinner();
numSolutionsSetter.setModel(new SpinnerNumberModel(1,1,Integer.MAX_VALUE,1));
label = new JLabel(LocalizationManager.get("nrSolutions"));
this.addAll(label, numSolutionsSetter);
SwingUtil.addAll(this,label, numSolutionsSetter);
}
@Override
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.Dimension;
......@@ -8,6 +29,7 @@ import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
......@@ -15,10 +37,10 @@ import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution;
@SuppressWarnings("serial")
public class SolutionTab extends ComfortPanel {
public class SolutionTab extends JPanel {
private final JScrollPane scrollPane;
private final ComfortPanel scrollPaneContent;
private final JPanel scrollPaneContent;
private final JLabel clusterCount;
private final JButton createMetaGraph;
......@@ -30,7 +52,7 @@ public class SolutionTab extends ComfortPanel {
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
//init swing components
scrollPaneContent = new ComfortPanel();
scrollPaneContent = new JPanel();
scrollPaneContent.setLayout(new BoxLayout(scrollPaneContent,BoxLayout.Y_AXIS));
for (YoshikoCluster c: solution.cluster) {
ClusterView clusterView = new ClusterView(c);
......@@ -52,7 +74,7 @@ public class SolutionTab extends ComfortPanel {
}
});
this.addAll(clusterCount,scrollPane,createMetaGraph);
SwingUtil.addAll(this,clusterCount,scrollPane,createMetaGraph);
}
}
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.JComponent;
import javax.swing.JPanel;
public class SwingUtil {
static void addAll(JPanel panel, JComponent ... components) {
for (JComponent c: components) {
panel.add(c);
}
}
}
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings("serial")
public class TimeLimitSetter extends ComfortPanel{
public class TimeLimitSetter extends JPanel{
private JCheckBox checkBox;
private IntegerInputField numberField;
......@@ -29,7 +51,7 @@ public class TimeLimitSetter extends ComfortPanel{
}
);
//REGISTER COMPONENTS
this.addAll(checkBox,numberField);
SwingUtil.addAll(this,checkBox,numberField);
}
@Override
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import java.io.File;
......
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader;
@SuppressWarnings("serial")
public class YoshikoHeader extends ComfortPanel {
public class YoshikoHeader extends JPanel {
private JLabel logo;
private JLabel text;
......@@ -15,10 +37,10 @@ public class YoshikoHeader extends ComfortPanel {
public YoshikoHeader() {
this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
logo = new JLabel(GraphicsLoader.getLogo());
text = new JLabel(GraphicsLoader.getText());
logo = new JLabel(GraphicsLoader.getLogo(32));
text = new JLabel(GraphicsLoader.getText(32));
this.addAll(logo,text);
SwingUtil.addAll(this,logo,text);
}
}
/*******************************************************************************
* 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
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.JDialog;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment