diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/GraphicsLoader.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/GraphicsLoader.java index 3590a50085ced087982e3d73b3b19fcd373e527c..2edb56cedf68030b8bcd46e9dc2f31def8249ed1 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/GraphicsLoader.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/GraphicsLoader.java @@ -21,6 +21,7 @@ ******************************************************************************/ package de.hhu.ba.yoshikoWrapper.core; +import java.awt.Color; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.IOException; @@ -30,15 +31,18 @@ import javax.swing.ImageIcon; public class GraphicsLoader { private static BufferedImage yoshikoLogo; + private static BufferedImage yoshikoLogo_solved; private static BufferedImage yoshikoText; + public final static Color yoshikoGreen = new Color(0,128,0); + private final static ClassLoader classLoader = GraphicsLoader.class.getClassLoader(); public static ImageIcon getLogo(int size) { if (yoshikoLogo == null) { try { yoshikoLogo = ImageIO.read( - classLoader.getResource("graphics/YoshikoAlphaLogo.png") + classLoader.getResource("graphics/YoshikoLogo.png") ); } catch (IOException e) { e.printStackTrace(); @@ -47,16 +51,31 @@ public class GraphicsLoader { return new ImageIcon(yoshikoLogo.getScaledInstance(size, size, Image.SCALE_SMOOTH)); } + public static ImageIcon getSolvedLogo(int size) { + if (yoshikoLogo_solved == null) { + try { + yoshikoLogo_solved = ImageIO.read( + classLoader.getResource("graphics/YoshikoSolved.png") + ); + } catch (IOException e) { + e.printStackTrace(); + } + } + return new ImageIcon(yoshikoLogo_solved.getScaledInstance(size, size, Image.SCALE_SMOOTH)); + } + + public static ImageIcon getText(int height) { + //Default dimension is 258x48 if (yoshikoText == null) { try { yoshikoText = ImageIO.read( - classLoader.getResource("graphics/YoshikoAlphaText.png") + classLoader.getResource("graphics/YoshikoText.png") ); } catch (IOException e) { e.printStackTrace(); } } - return new ImageIcon(yoshikoText.getScaledInstance(height*4, height, Image.SCALE_SMOOTH)); + return new ImageIcon(yoshikoText.getScaledInstance((int)(height*258/48), height, Image.SCALE_SMOOTH)); } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ComfortCollapsiblePanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ComfortCollapsiblePanel.java deleted file mode 100644 index 9292f723d995d563d4613ebdf11ec3814293dbf2..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ComfortCollapsiblePanel.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.hhu.ba.yoshikoWrapper.gui; - -import org.cytoscape.util.swing.BasicCollapsiblePanel; - -@SuppressWarnings("serial") -public class ComfortCollapsiblePanel extends BasicCollapsiblePanel { - - public ComfortCollapsiblePanel(String text) { - super(text); - } - - @Override - public void setCollapsed(boolean collapse) { - super.setCollapsed(collapse); - //Force resize of parent - if (getParent() != null) { - getParent().revalidate(); - } - } -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/EditCostPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/EditCostPanel.java index 0277bcd6562c61ed29e8e23cdf854bdc224a09fd..8a134bb7faae9532a7a52df7e7acd87315b8b2a7 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/EditCostPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/EditCostPanel.java @@ -21,11 +21,11 @@ ******************************************************************************/ package de.hhu.ba.yoshikoWrapper.gui; -import java.awt.FlowLayout; -import javax.swing.BoxLayout; +import javax.swing.GroupLayout; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.GroupLayout.Alignment; import org.cytoscape.model.CyColumn; import org.cytoscape.util.swing.BasicCollapsiblePanel; @@ -49,8 +49,7 @@ public class EditCostPanel extends BasicCollapsiblePanel { public EditCostPanel() { super(LocalizationManager.get("editingCostPanel")); - //Define Layout - this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); + //Initialize components columnMapper = new ColumnMapper(); @@ -66,18 +65,30 @@ public class EditCostPanel extends BasicCollapsiblePanel { //Group the labels with their text fields groupIC = new JPanel(); groupDC = new JPanel(); - - groupIC.setLayout(new FlowLayout()); - groupDC.setLayout(new FlowLayout()); SwingUtil.addAll(groupIC,icLabel,icField); SwingUtil.addAll(groupDC,dcLabel,dcField); SwingUtil.addAll(this,columnMapper,groupIC,groupDC); - //Decoration/Visual - //Border border = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); - //this.setBorder(border); + + //Layout + GroupLayout layout = new GroupLayout(this.getContentPane()); + + layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true) + .addComponent(columnMapper) + .addComponent(groupIC) + .addComponent(groupDC) + ); + + layout.setVerticalGroup(layout.createSequentialGroup() + .addComponent(columnMapper) + .addComponent(groupIC) + .addComponent(groupDC) + ); + + this.getContentPane().setLayout(layout); + } //SETTER / GETTER @@ -105,7 +116,5 @@ public class EditCostPanel extends BasicCollapsiblePanel { public ColumnMapper getColumnMapper() { return columnMapper; } - - } 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 6773d7a6aca2cdd14f7401e62a8dd81e36f7ce22..942ae8f8311dc27d0b0e12052afc8d55fc256f26 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcher.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcher.java @@ -49,6 +49,7 @@ public class LanguageSwitcher extends JComboBox<Locale>{ } }); + } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcherPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcherPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..aa8c5a78ceedba6c1cfea373aaf686c92058f3fb --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LanguageSwitcherPanel.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * 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 org.cytoscape.util.swing.BasicCollapsiblePanel; + +import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; + +@SuppressWarnings("serial") +public class LanguageSwitcherPanel extends BasicCollapsiblePanel{ + + private final LanguageSwitcher switcher; + + public LanguageSwitcherPanel() { + super(LocalizationManager.get("switchLanguage")); + this.getContentPane().setLayout(new BoxLayout(this.getContentPane(),BoxLayout.X_AXIS)); + //SWING COMPONENTS INIT + switcher = new LanguageSwitcher(); + + SwingUtil.addAll(this, + switcher + ); + } + +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibStatusPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibStatusPanel.java index a24bfdc32ec03b6593527b9ff064412574ec70ea..f1690c032b4f76587bd79a0584219e33fe736e90 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibStatusPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibStatusPanel.java @@ -25,6 +25,8 @@ import java.awt.Color; import javax.swing.JLabel; +import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader; + public class LibStatusPanel extends JLabel { /** @@ -35,7 +37,7 @@ public class LibStatusPanel extends JLabel { public void setStyle(boolean libraryLoaded) { if(libraryLoaded) { this.setText("YOSHIKO LIBRARY READY!"); - this.setForeground(Color.GREEN); + this.setForeground(GraphicsLoader.yoshikoGreen); } else { this.setText("YOSHIKO LIBRARY NOT LOADED :("); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibraryPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibraryPanel.java index bdb7f21577d1c17bea0ad0f9d7ed32dce0278ba9..6267c168329641119ccd01fe00cfaf54a2fad8ed 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibraryPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibraryPanel.java @@ -24,12 +24,12 @@ package de.hhu.ba.yoshikoWrapper.gui; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; +import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JLabel; -import javax.swing.border.EtchedBorder; +import javax.swing.GroupLayout.Alignment; + import org.cytoscape.util.swing.BasicCollapsiblePanel; @@ -38,7 +38,7 @@ import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; @SuppressWarnings("serial") -public class LibraryPanel extends ComfortCollapsiblePanel { +public class LibraryPanel extends BasicCollapsiblePanel { //SYMBOLIC LINKS private LibraryPanel self = this; @@ -50,7 +50,6 @@ public class LibraryPanel extends ComfortCollapsiblePanel { public LibraryPanel() { super(LocalizationManager.get("libraryPanel")); - this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); //SWING COMPONENT INITIALIZATION libStatusPanel = new LibStatusPanel(); searchLibButton = new JButton(LocalizationManager.get("resolveLibPath")); @@ -63,7 +62,6 @@ public class LibraryPanel extends ComfortCollapsiblePanel { searchLibButton.setEnabled(false); } - searchLibButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -78,7 +76,29 @@ public class LibraryPanel extends ComfortCollapsiblePanel { } }); - SwingUtil.addAll(this,libStatusPanel,yoshikoVersionLabel,searchLibButton); + SwingUtil.addAll(this, + libStatusPanel, + yoshikoVersionLabel, + searchLibButton + ); + + //Layout + GroupLayout layout = new GroupLayout(this.getContentPane()); + + layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true) + .addComponent(libStatusPanel) + .addComponent(yoshikoVersionLabel) + .addComponent(searchLibButton) + ); + + layout.setVerticalGroup(layout.createSequentialGroup() + .addComponent(libStatusPanel) + .addComponent(yoshikoVersionLabel) + .addComponent(searchLibButton) + ); + + + this.getContentPane().setLayout(layout); } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java index 23480f3cb283cae134abc16c09486580ca6fa656..cbfa232ebb256f4a5ae383e8da89ed0c71a8ce18 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java @@ -21,22 +21,21 @@ ******************************************************************************/ package de.hhu.ba.yoshikoWrapper.gui; +import static javax.swing.GroupLayout.DEFAULT_SIZE; +import static javax.swing.GroupLayout.PREFERRED_SIZE; + 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; @@ -61,19 +60,14 @@ public class MainPanel extends JPanel implements CytoPanelComponent { private final YoshikoHeader header; - /** - * Swing is a bit special sometimes, so a panel is used to wrap the lang-switcher. - * This prevents stretching of the component - */ - private final JPanel langSwitcherWrapper; - private final LanguageSwitcher langSwitcher; + private final JCheckBox showAdvancedOptions; + private final ArrayList<JComponent> advancedOptions; + + private final LanguageSwitcherPanel langPanel; private final LibraryPanel libraryPanel; private final EditCostPanel ecPanel; private final ReductionRulesChooser reductionRulesChooser; - private final OperationModePanel opModePanel; - - //OTHER - + private final OperationModePanel opModePanel; /** * Main constructor, creates a new Panel and initializes subcomponents @@ -86,19 +80,18 @@ public class MainPanel extends JPanel implements CytoPanelComponent { //Initialize Swing components header = new YoshikoHeader(); - langSwitcherWrapper = new JPanel(); - langSwitcher = new LanguageSwitcher(); - langSwitcherWrapper.add(new JLabel(LocalizationManager.get("switchLanguage"))); - langSwitcherWrapper.add(langSwitcher); - langSwitcherWrapper.setLayout(new FlowLayout()); + showAdvancedOptions = new JCheckBox(LocalizationManager.get("showAdvanced")); + showAdvancedOptions.addActionListener(toggleAdvancedOptionsListener); + + langPanel = new LanguageSwitcherPanel(); libraryPanel = new LibraryPanel(); + //If no library is loaded yet the obvious panel should be showing up if (!YoshikoLoader.isLibraryLoaded()) { libraryPanel.setCollapsed(false); } ecPanel = new EditCostPanel(); - ecPanel.setCollapsed(false); opModePanel = new OperationModePanel(); @@ -107,44 +100,79 @@ public class MainPanel extends JPanel implements CytoPanelComponent { JButton runButton = new JButton(LocalizationManager.get("run")); runButton.addActionListener(buttonListener); + //Add components to main panel + SwingUtil.addAll(this, header, - langSwitcherWrapper, + showAdvancedOptions, + langPanel, libraryPanel, ecPanel, reductionRulesChooser, opModePanel, runButton - ); - + ); + + //Manage all advanced components separately to enable toggling + advancedOptions = new ArrayList<JComponent>(); + advancedOptions.addAll( + Arrays.asList( + opModePanel, + reductionRulesChooser + ) + ); + + showAdvancedOptions(false); //Layout GroupLayout layout = new GroupLayout(this); + layout.setAutoCreateGaps(true); + layout.setAutoCreateContainerGaps(true); - layout.setHorizontalGroup(layout.createParallelGroup() - .addComponent(header) - .addComponent(langSwitcherWrapper) - .addComponent(libraryPanel) - .addComponent(ecPanel) - .addComponent(reductionRulesChooser) - .addComponent(opModePanel) - .addComponent(runButton) + layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true) + .addGap(30) + .addComponent(header,DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(showAdvancedOptions,DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(langPanel,DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(libraryPanel,PREFERRED_SIZE, PREFERRED_SIZE, Short.MAX_VALUE) + .addComponent(ecPanel,DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(reductionRulesChooser,DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(opModePanel,DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(runButton,DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup(layout.createSequentialGroup() - .addComponent(header) - .addComponent(langSwitcherWrapper) - .addComponent(libraryPanel) - .addComponent(ecPanel) - .addComponent(reductionRulesChooser) - .addComponent(opModePanel) - .addComponent(runButton) + .addComponent(header,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) + .addComponent(showAdvancedOptions,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) + .addComponent(langPanel,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) + .addComponent(libraryPanel,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) + .addComponent(ecPanel,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) + .addComponent(reductionRulesChooser,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) + .addComponent(opModePanel,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) + .addComponent(runButton,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) ); this.setLayout(layout); + + + } + + private ActionListener toggleAdvancedOptionsListener = new ActionListener() { - this.setVisible(true); + @Override + public void actionPerformed(ActionEvent e) { + showAdvancedOptions(showAdvancedOptions.isSelected()); + } + + }; + + private void showAdvancedOptions(boolean show) { + for (JComponent j : advancedOptions) { + j.setVisible(show); + } + setPreferredSize(getPreferredSize()); // <<< Swing at its finest + revalidate(); } /** diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/OperationModePanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/OperationModePanel.java index f0fa03c1e1094511aef6aee1e651377552da9ebd..e3d38c77e2223e3fb57d2101b0121848dcb852ae 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/OperationModePanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/OperationModePanel.java @@ -24,20 +24,24 @@ package de.hhu.ba.yoshikoWrapper.gui; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; +import static javax.swing.GroupLayout.DEFAULT_SIZE; + import javax.swing.ButtonGroup; +import javax.swing.GroupLayout; import javax.swing.JCheckBox; import javax.swing.JRadioButton; -import javax.swing.border.Border; -import javax.swing.border.EtchedBorder; import org.cytoscape.util.swing.BasicCollapsiblePanel; +import javax.swing.GroupLayout.Alignment; + + import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; @SuppressWarnings("serial") -public class OperationModePanel extends ComfortCollapsiblePanel{ +public class OperationModePanel extends BasicCollapsiblePanel{ + + //SWING COMPONENTS private final JRadioButton useHeuristic; private final JRadioButton useILP; private final TimeLimitSetter timeLimitSetter; @@ -48,8 +52,8 @@ public class OperationModePanel extends ComfortCollapsiblePanel{ private final ButtonGroup heuristicGroup; public OperationModePanel() { + super(LocalizationManager.get("operationMode")); - this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); heuristicGroup = new ButtonGroup(); useILP = new JRadioButton("Use Integer Linear Programming"); @@ -61,7 +65,6 @@ public class OperationModePanel extends ComfortCollapsiblePanel{ solutionNumberChooser = new SolutionNumberChooser(); - timeLimitSetter = new TimeLimitSetter(); useTriangleCutsBox = new JCheckBox("Use Triangle Cuts"); @@ -70,10 +73,41 @@ public class OperationModePanel extends ComfortCollapsiblePanel{ //Link time limit option to ILP useILP.addActionListener(ilpHeuristicSwitch); useHeuristic.addActionListener(ilpHeuristicSwitch); - - SwingUtil.addAll(this,useILP,useHeuristic,solutionNumberChooser,timeLimitSetter,useTriangleCutsBox,usePartitionCutsBox); + SwingUtil.addAll(this, + useILP, + useHeuristic, + solutionNumberChooser, + timeLimitSetter, + useTriangleCutsBox, + usePartitionCutsBox + ); + //Layout + GroupLayout layout = new GroupLayout(this.getContentPane()); + + 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(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) + ); + + layout.setVerticalGroup(layout.createSequentialGroup() + .addComponent(useILP) + .addComponent(useHeuristic) + .addComponent(solutionNumberChooser) + .addComponent(timeLimitSetter) + .addComponent(useTriangleCutsBox) + .addComponent(usePartitionCutsBox) + ); + + this.getContentPane().setLayout(layout); + } ActionListener ilpHeuristicSwitch = new ActionListener() { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ReductionRulesChooser.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ReductionRulesChooser.java index 074cd3460e78051ddbc61448236a9f7f4b3d991f..00dc45c70bd254a30a02fb2df909d232f77ea3e1 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ReductionRulesChooser.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ReductionRulesChooser.java @@ -21,19 +21,24 @@ ******************************************************************************/ package de.hhu.ba.yoshikoWrapper.gui; +import static javax.swing.GroupLayout.DEFAULT_SIZE; + import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BoxLayout; +import javax.swing.GroupLayout; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.GroupLayout.Alignment; +import org.cytoscape.util.swing.BasicCollapsiblePanel; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; @SuppressWarnings("serial") -public class ReductionRulesChooser extends ComfortCollapsiblePanel{ +public class ReductionRulesChooser extends BasicCollapsiblePanel{ private final JCheckBox useCRule; private final JCheckBox useCCRule; @@ -48,8 +53,8 @@ public class ReductionRulesChooser extends ComfortCollapsiblePanel{ public ReductionRulesChooser() { + super(LocalizationManager.get("redRuleChooserTitle")); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); //Initialize subcomponents useCRule = new JCheckBox("Use Clique Rule"); useCCRule = new JCheckBox("Use Critical-Clique Rule"); @@ -60,7 +65,7 @@ public class ReductionRulesChooser extends ComfortCollapsiblePanel{ multFactor = new DoubleInputField(1, Double.POSITIVE_INFINITY); multFactor.setText("1.0"); SNPanel = new JPanel(); - + SNPanel.setLayout(new BoxLayout(SNPanel,BoxLayout.X_AXIS)); SwingUtil.addAll(SNPanel,new JLabel(LocalizationManager.get("multFactor")),multFactor); useSNRule.setSelected(true); @@ -92,6 +97,34 @@ public class ReductionRulesChooser extends ComfortCollapsiblePanel{ useSNRule, SNPanel ); + + //Layout + GroupLayout layout = new GroupLayout(this.getContentPane()); + + layout.setAutoCreateGaps(true); + + layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true) + .addComponent(useCRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useCCRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useACRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useHERule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(usePDRRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useSNRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(SNPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + ); + + layout.setVerticalGroup(layout.createSequentialGroup() + .addComponent(useCRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useCCRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useACRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useHERule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(usePDRRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(useSNRule, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(SNPanel, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE) + ); + + this.getContentPane().setLayout(layout); + } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ResultPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ResultPanel.java index a6515d33198d91aab43955683da3447e604622a1..de3ab6f801977bdd1378d80bbfc10a1484f13308 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ResultPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/ResultPanel.java @@ -25,7 +25,7 @@ import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import javax.swing.BoxLayout; +import javax.swing.GroupLayout; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JLabel; @@ -51,21 +51,25 @@ public class ResultPanel extends JPanel implements CytoPanelComponent{ private final JTabbedPane solutionTabs; private final JLabel costLabel; private final JButton destroyButton; + private final JLabel optimalLabel; private final YoshikoResult result; public ResultPanel(YoshikoResult result) { this.result = result; - - setLayout(new BoxLayout(this,BoxLayout.Y_AXIS)); - + //Init subcomponents solutionTabs = new JTabbedPane(); for (YoshikoSolution s : result.solutions) { addSolutionTab(s); } + + //TODO + optimalLabel = new JLabel("Optimal"); + optimalLabel.setForeground(GraphicsLoader.yoshikoGreen); + costLabel = new JLabel(); setCost(result.editingCost); @@ -79,7 +83,33 @@ public class ResultPanel extends JPanel implements CytoPanelComponent{ }); - SwingUtil.addAll(this,costLabel,solutionTabs,destroyButton); + SwingUtil.addAll(this,optimalLabel,costLabel,solutionTabs,destroyButton); + + //Layout + GroupLayout layout = new GroupLayout(this); + + layout.setAutoCreateGaps(true); + layout.setAutoCreateContainerGaps(true); + + layout.setVerticalGroup(layout.createSequentialGroup() + .addComponent(costLabel) + .addComponent(optimalLabel) + .addComponent(solutionTabs) + .addComponent(destroyButton) + ); + + + + + layout.setHorizontalGroup(layout.createParallelGroup() + .addComponent(costLabel) + .addComponent(optimalLabel) + .addComponent(solutionTabs) + .addComponent(destroyButton) + ); + + + this.setLayout(layout); } public void deleteSolution() { @@ -129,7 +159,11 @@ public class ResultPanel extends JPanel implements CytoPanelComponent{ @Override public Icon getIcon() { - return GraphicsLoader.getLogo(16); + return GraphicsLoader.getSolvedLogo(16); + } + + public YoshikoResult getResult() { + return result; } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java index 81afa9bda5be7f95c6cd2593ba16f6dfb1349489..576e6de9c8cd3ec5dd57e39a6d34b8652cc31ce0 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java @@ -24,6 +24,7 @@ package de.hhu.ba.yoshikoWrapper.gui; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.BoxLayout; import javax.swing.JCheckBox; import javax.swing.JPanel; @@ -36,20 +37,21 @@ public class TimeLimitSetter extends JPanel{ private IntegerInputField numberField; public TimeLimitSetter() { + this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS)); checkBox = new JCheckBox(LocalizationManager.get("timeLimitILP")); numberField = new IntegerInputField(); numberField.setText("60"); numberField.setEnabled(false); //By default time limit is turned off checkBox.addActionListener( - new ActionListener() { + new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - numberField.setEnabled(checkBox.isSelected()); - } - + @Override + public void actionPerformed(ActionEvent e) { + numberField.setEnabled(checkBox.isSelected()); } - ); + + } + ); //REGISTER COMPONENTS SwingUtil.addAll(this,checkBox,numberField); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHeader.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHeader.java index 889a03ba4b84cf4e443511a319430607212667f5..46846446a3c1c4f6d663c15c812132a2db3dff28 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHeader.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YoshikoHeader.java @@ -22,6 +22,7 @@ package de.hhu.ba.yoshikoWrapper.gui; +import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JPanel; @@ -40,7 +41,8 @@ public class YoshikoHeader extends JPanel { logo = new JLabel(GraphicsLoader.getLogo(32)); text = new JLabel(GraphicsLoader.getText(32)); - SwingUtil.addAll(this,logo,text); - + this.add(logo); + this.add(Box.createHorizontalStrut(4)); + this.add(text); } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/package-info.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/package-info.java index 602043fa71d32602f9bdc2482005a7b586ccd3c6..e0d4d454fb10c0039e2f7c7a05ef3d05fa625854 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/package-info.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/package-info.java @@ -19,6 +19,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. ******************************************************************************/ + /**This package contains all Swing extensions and components (frontend) * */ diff --git a/src/main/resources/YoshikoStrings.properties b/src/main/resources/YoshikoStrings.properties index 1ecfdc7ff7ee9efb86c83e1d3e481a677eb72668..fa80efda284b8c8c3f0529af1ca83499530333c8 100644 --- a/src/main/resources/YoshikoStrings.properties +++ b/src/main/resources/YoshikoStrings.properties @@ -48,7 +48,7 @@ editingCostPanel = Editing Costs libraryPanel = Library defaultInsertion = Default insertion cost: defaultDeletion = Default deletion cost: -switchLanguage = Plugin language: +switchLanguage = Plugin language icTooltip = This value is used to determine what the algorithm pays when inserting an edge. Existing mappings overwrite this value. A higher value means that the algorithm is less likely to insert edges in order to generate a cluster. operationMode = Operation Mode run = Perform Algorithm diff --git a/src/main/resources/graphics/YoshikoAlphaLogo.png b/src/main/resources/graphics/YoshikoAlphaLogo.png deleted file mode 100644 index f13dc35cf24becfe8be3f416884073b36b04f8ea..0000000000000000000000000000000000000000 Binary files a/src/main/resources/graphics/YoshikoAlphaLogo.png and /dev/null differ diff --git a/src/main/resources/graphics/YoshikoAlphaText.png b/src/main/resources/graphics/YoshikoAlphaText.png deleted file mode 100644 index 5d9b127ace12d72208f05f4d3633ee0ed0f0472c..0000000000000000000000000000000000000000 Binary files a/src/main/resources/graphics/YoshikoAlphaText.png and /dev/null differ diff --git a/src/main/resources/graphics/YoshikoLogo.png b/src/main/resources/graphics/YoshikoLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..f71daaa2bec19e27195c3d5d229a50e607761bf0 Binary files /dev/null and b/src/main/resources/graphics/YoshikoLogo.png differ diff --git a/src/main/resources/graphics/YoshikoSolved.png b/src/main/resources/graphics/YoshikoSolved.png new file mode 100644 index 0000000000000000000000000000000000000000..f1631b52749f39c677cc1db46262a9f1227a8090 Binary files /dev/null and b/src/main/resources/graphics/YoshikoSolved.png differ diff --git a/src/main/resources/graphics/YoshikoText.png b/src/main/resources/graphics/YoshikoText.png new file mode 100644 index 0000000000000000000000000000000000000000..b6b0025ed2f9031f564425f0100530ba6e12f083 Binary files /dev/null and b/src/main/resources/graphics/YoshikoText.png differ diff --git a/src/main/resources/graphics/flags/deDE.svg b/src/main/resources/graphics/flags/deDE.svg new file mode 100644 index 0000000000000000000000000000000000000000..7af71b97c30f7323cb099a7b24f7fc112ae2d921 --- /dev/null +++ b/src/main/resources/graphics/flags/deDE.svg @@ -0,0 +1,5 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="512" width="512" viewBox="0 0 512 512"> + <path fill="#ffce00" d="M0 341.338h512.005v170.67H0z"/> + <path d="M0 0h512.005v170.67H0z"/> + <path fill="#d00" d="M0 170.67h512.005v170.668H0z"/> +</svg> diff --git a/src/main/resources/graphics/flags/enUS.svg b/src/main/resources/graphics/flags/enUS.svg new file mode 100644 index 0000000000000000000000000000000000000000..15d50af6a1c4dabe9602035d32c55c0d56e993a1 --- /dev/null +++ b/src/main/resources/graphics/flags/enUS.svg @@ -0,0 +1,18 @@ +<svg xmlns="http://www.w3.org/2000/svg" height="512" width="512" viewBox="0 0 512 512"> + <g fill-rule="evenodd" transform="scale(3.9385)"> + <g stroke-width="1pt"> + <path d="M0 0h247v10H0zm0 20h247v10H0zm0 20h247v10H0zm0 20h247v10H0zm0 20h247v10H0zm0 20h247v10H0zm0 20h247v10H0z" fill="#bd3d44"/> + <path d="M0 10h247v10H0zm0 20h247v10H0zm0 20h247v10H0zm0 20h247v10H0zm0 20h247v10H0zm0 20h247v10H0z" fill="#fff"/> + </g> + <path fill="#192f5d" d="M0 0h98.8v70H0z"/> + <g fill="#fff"> + <path d="M8.233 2.996l.9 2.767h2.908l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766L24.7 8.53l-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766L74.1 8.53l-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zM16.467 9.996l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zM8.233 16.996l.9 2.767h2.908l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zM16.467 23.996l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zM8.233 30.996l.9 2.767h2.908l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zM16.467 37.996l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909z"/> + <g> + <path d="M8.233 44.996l.9 2.767h2.908l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zM16.467 51.996l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909z"/> + </g> + <g> + <path d="M8.233 58.996l.9 2.767h2.908l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.353 1.71.898 2.766-2.353-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.466 0l.899 2.767h2.909l-2.353 1.71.899 2.766-2.354-1.71-2.353 1.71.899-2.766-2.354-1.71h2.91zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909zm16.467 0l.899 2.767h2.909l-2.354 1.71.9 2.766-2.354-1.71-2.353 1.71.898-2.766-2.353-1.71h2.909z"/> + </g> + </g> + </g> +</svg>