Skip to content
Snippets Groups Projects
Commit b5929a70 authored by unknown's avatar unknown
Browse files

removed unused features from user-interface

parent 28dcd252
No related branches found
No related tags found
No related merge requests found
package de.hhu.ba.yoshikoWrapper.swing.components;
import java.awt.Component;
import java.util.Locale;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader;
@SuppressWarnings("serial")
class LanguageRenderer extends JPanel implements ListCellRenderer<Locale>{
private static final int FLAG_SIZE_X = 36;
private static final int FLAG_SIZE_Y = 18;
private final JLabel label;
public LanguageRenderer() {
label = new JLabel();
this.add(label);
}
@Override
public Component getListCellRendererComponent(
JList<? extends Locale> list,
Locale value,
int index,
boolean isSelected,
boolean cellHasFocus)
{
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
label.setIcon(GraphicsLoader.getFlag(value, FLAG_SIZE_X, FLAG_SIZE_Y));
label.setText(value.getDisplayLanguage());
return this;
}
}
/*******************************************************************************
* 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.swing.components;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
@SuppressWarnings( "serial")
public class LanguageSwitcher extends JComboBox<Locale>{
public LanguageSwitcher() {
this.setRenderer(new LanguageRenderer());
for (Locale l: LocalizationManager.getLocales() ) {
this.addItem(l);
if (LocalizationManager.getCurrentLocale() == l) {
this.setSelectedItem(l);
}
}
this.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
LocalizationManager.switchLanguage(getItemAt(getSelectedIndex()));
JOptionPane.showMessageDialog(null,LocalizationManager.get("restartNeeded"));
}
});
}
}
/*******************************************************************************
* 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.swing.components;
import javax.swing.JPanel;
import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
@SuppressWarnings("serial")
public class LanguageSwitcherPanel extends JPanel{
final private LanguageSwitcher switcher;
public LanguageSwitcherPanel() {
switcher = new LanguageSwitcher();
SwingUtil.addAll(this,
switcher
);
}
}
...@@ -76,8 +76,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -76,8 +76,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
private final YoshikoHeader header; private final YoshikoHeader header;
private final JButton about;
private final JCheckBox showAdvancedOptions; private final JCheckBox showAdvancedOptions;
private final ArrayList<JComponent> advancedOptions; private final ArrayList<JComponent> advancedOptions;
...@@ -85,21 +83,11 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -85,21 +83,11 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
private final JScrollPane scrollPane; private final JScrollPane scrollPane;
private final JPanel scrollableContent; private final JPanel scrollableContent;
/**
* Panel for selecting the application language
*/
private final LanguageSwitcherPanel langPanel;
private final BasicCollapsiblePanel langWrapper;
//Those don't work really as collapsible panels and cause glitches which forces the workaround of wrapping them //Those don't work really as collapsible panels and cause glitches which forces the workaround of wrapping them
//Probably someone used getClass() == instead of instanceof so extending BasicCollapsiblePanel is sadly not possible //Probably someone used getClass() == instead of instanceof so extending BasicCollapsiblePanel is sadly not possible
private final BasicCollapsiblePanel ecPanelWrapper; private final BasicCollapsiblePanel ecPanelWrapper;
private final EditCostPanel ecPanel; private final EditCostPanel ecPanel;
private final BasicCollapsiblePanel reductionWrapper;
private final ReductionRulesChooser reductionRulesChooser;
private final BasicCollapsiblePanel opWrapper; private final BasicCollapsiblePanel opWrapper;
private final OperationModePanel opModePanel; private final OperationModePanel opModePanel;
...@@ -113,29 +101,13 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -113,29 +101,13 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
//Initialize Swing components //Initialize Swing components
header = new YoshikoHeader(); header = new YoshikoHeader();
about = new JButton(LocalizationManager.get("aboutButton"),GraphicsLoader.getInfoIcon(16));
about.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CommandExecutor.executeCommand("cybrowser", "show",HelpLinks.mainInfo , null);
//TODO: Auto select CyBrowser tab
}
});
showAdvancedOptions = new JCheckBox(LocalizationManager.get("showAdvanced")); showAdvancedOptions = new JCheckBox(LocalizationManager.get("showAdvanced"));
showAdvancedOptions.addActionListener(toggleAdvancedOptionsListener);
scrollableContent = new JPanel(); scrollableContent = new JPanel();
scrollPane = new JScrollPane(scrollableContent); scrollPane = new JScrollPane(scrollableContent);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(BorderFactory.createEmptyBorder()); scrollPane.setBorder(BorderFactory.createEmptyBorder());
langPanel = new LanguageSwitcherPanel();
langWrapper = new BasicCollapsiblePanel(LocalizationManager.get("switchLanguage"));
langWrapper.add(langPanel);
ecPanel = new EditCostPanel(); ecPanel = new EditCostPanel();
ecPanelWrapper = new BasicCollapsiblePanel(LocalizationManager.get("editingCostPanel")); ecPanelWrapper = new BasicCollapsiblePanel(LocalizationManager.get("editingCostPanel"));
ecPanelWrapper.add(ecPanel); ecPanelWrapper.add(ecPanel);
...@@ -144,27 +116,20 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -144,27 +116,20 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
opModePanel = new OperationModePanel(); opModePanel = new OperationModePanel();
opWrapper = new BasicCollapsiblePanel(LocalizationManager.get("operationMode")); opWrapper = new BasicCollapsiblePanel(LocalizationManager.get("operationMode"));
opWrapper.add(opModePanel); opWrapper.add(opModePanel);
opWrapper.setCollapsed(false);
reductionWrapper = new BasicCollapsiblePanel(LocalizationManager.get("redRuleChooserTitle"));
reductionRulesChooser = new ReductionRulesChooser();
reductionWrapper.add(reductionRulesChooser);
runButton = new JButton(LocalizationManager.get("run")); runButton = new JButton(LocalizationManager.get("run"));
runButton.addActionListener(buttonListener); runButton.addActionListener(buttonListener);
//Add components to the scrollable part of the main panel //Add components to the scrollable part of the main panel
SwingUtil.addAll(scrollableContent, SwingUtil.addAll(scrollableContent,
langWrapper,
ecPanelWrapper, ecPanelWrapper,
reductionWrapper,
opWrapper opWrapper
); );
//Add the 'fixed' components to the main panel //Add the 'fixed' components to the main panel
SwingUtil.addAll(this, SwingUtil.addAll(this,
header, header,
about,
showAdvancedOptions,
scrollPane, scrollPane,
runButton runButton
); );
...@@ -173,12 +138,11 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -173,12 +138,11 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
advancedOptions = new ArrayList<JComponent>(); advancedOptions = new ArrayList<JComponent>();
advancedOptions.addAll( advancedOptions.addAll(
Arrays.asList( Arrays.asList(
opWrapper, opWrapper
reductionWrapper
) )
); );
showAdvancedOptions(false); showAdvancedOptions(true);
applyLayout(); applyLayout();
} }
...@@ -199,36 +163,28 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -199,36 +163,28 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
.addComponent(header,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(header,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
//"SPRING" Functionality ; eats all the space that is available //"SPRING" Functionality ; eats all the space that is available
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(about,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
) )
.addGap(8) .addGap(8)
.addComponent(showAdvancedOptions,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(scrollPane,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(scrollPane,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(runButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(runButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
); );
scrollLayout.setHorizontalGroup(scrollLayout.createParallelGroup(Alignment.LEADING,true) scrollLayout.setHorizontalGroup(scrollLayout.createParallelGroup(Alignment.LEADING,true)
.addComponent(langWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(ecPanelWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(opWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(opWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE)
); );
layout.setVerticalGroup(layout.createSequentialGroup() layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup() .addGroup(layout.createParallelGroup()
.addComponent(header,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(header,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(about,Alignment.TRAILING,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
) )
.addGap(8) .addGap(8)
.addComponent(showAdvancedOptions,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(runButton,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(runButton,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
); );
scrollLayout.setVerticalGroup(scrollLayout.createSequentialGroup() scrollLayout.setVerticalGroup(scrollLayout.createSequentialGroup()
.addComponent(langWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(ecPanelWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(ecPanelWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(reductionWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(opWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(opWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
); );
...@@ -237,14 +193,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -237,14 +193,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
this.setLayout(layout); this.setLayout(layout);
} }
private ActionListener toggleAdvancedOptionsListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showAdvancedOptions(showAdvancedOptions.isSelected());
}
};
private void showAdvancedOptions(boolean show) { private void showAdvancedOptions(boolean show) {
for (JComponent j : advancedOptions) { for (JComponent j : advancedOptions) {
...@@ -316,9 +264,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -316,9 +264,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
ret.defaultInsertionCost = ecPanel.getDefaultInsertionCost(); ret.defaultInsertionCost = ecPanel.getDefaultInsertionCost();
ret.defaultDeletionCost = ecPanel.getDefaultDeletionCost(); ret.defaultDeletionCost = ecPanel.getDefaultDeletionCost();
ret.useHeuristic = opModePanel.useHeuristic(); ret.useHeuristic = opModePanel.useHeuristic();
ret.reductionRulesBitMask = reductionRulesChooser.getBitMask();
ret.suggestReduction = reductionRulesChooser.useAutoConfig();
ret.snrMultFactor = reductionRulesChooser.getMultFactor();
ret.useTriangleCuts = opModePanel.useTriangleCuts(); ret.useTriangleCuts = opModePanel.useTriangleCuts();
ret.usePartitionCuts = opModePanel.usePartitionCuts(); ret.usePartitionCuts = opModePanel.usePartitionCuts();
ret.solCount = opModePanel.getSolCount(); ret.solCount = opModePanel.getSolCount();
......
...@@ -88,14 +88,7 @@ public class OperationModePanel extends JPanel{ ...@@ -88,14 +88,7 @@ public class OperationModePanel extends JPanel{
SwingUtil.addAll(this, SwingUtil.addAll(this,
useClusterCount, useClusterCount,
ccChooser, ccChooser
useHeuristic,
useILP,
solutionNumberChooser,
timeLimitSetter,
useTriangleCutsBox,
usePartitionCutsBox,
disableMultiThreading
); );
//We set all components to enabled/disabled according to mode //We set all components to enabled/disabled according to mode
...@@ -109,25 +102,11 @@ public class OperationModePanel extends JPanel{ ...@@ -109,25 +102,11 @@ public class OperationModePanel extends JPanel{
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true) layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true)
.addComponent(useClusterCount, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(useClusterCount, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(ccChooser, DEFAULT_SIZE, DEFAULT_SIZE, DEFAULT_SIZE) .addComponent(ccChooser, DEFAULT_SIZE, DEFAULT_SIZE, DEFAULT_SIZE)
.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() layout.setVerticalGroup(layout.createSequentialGroup()
.addComponent(useClusterCount) .addComponent(useClusterCount)
.addComponent(ccChooser) .addComponent(ccChooser)
.addComponent(useHeuristic)
.addComponent(useILP)
.addComponent(solutionNumberChooser)
.addComponent(timeLimitSetter)
.addComponent(useTriangleCutsBox)
.addComponent(usePartitionCutsBox)
.addComponent(disableMultiThreading)
); );
this.setLayout(layout); this.setLayout(layout);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment