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

As always, swing requires lots of patience

parent 446f76bf
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
******************************************************************************/ ******************************************************************************/
package de.hhu.ba.yoshikoWrapper.swing.components; package de.hhu.ba.yoshikoWrapper.swing.components;
import static javax.swing.GroupLayout.DEFAULT_SIZE;
import static javax.swing.GroupLayout.PREFERRED_SIZE;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
...@@ -73,12 +76,10 @@ public class ClusterView extends JPanel { ...@@ -73,12 +76,10 @@ public class ClusterView extends JPanel {
title = new JLabel(LocalizationManager.get("cluster")+" "+(c.getID()+1)); title = new JLabel(LocalizationManager.get("cluster")+" "+(c.getID()+1));
clusterSize = new JLabel(LocalizationManager.get("clusterSize")+" "+c.getSize()); clusterSize = new JLabel(LocalizationManager.get("clusterSize")+" "+c.getSize());
icon = new JLabel(); icon = new JLabel();
icon.setPreferredSize(new Dimension(CLUSTER_ICON_SIZE,CLUSTER_ICON_SIZE)); //icon.setBorder(BorderFactory.createLineBorder(Color.BLACK));
icon.setBorder(BorderFactory.createLineBorder(Color.BLACK));
cluster.applyImage(icon,CLUSTER_ICON_SIZE, CLUSTER_ICON_SIZE); cluster.applyImage(icon,CLUSTER_ICON_SIZE, CLUSTER_ICON_SIZE);
SwingUtil.addAll(this,title,clusterSize,icon); SwingUtil.addAll(this,title,clusterSize,icon);
this.add(Box.createVerticalStrut(4));
nodeList = new BasicCollapsiblePanel(LocalizationManager.get("nodes")); nodeList = new BasicCollapsiblePanel(LocalizationManager.get("nodes"));
...@@ -97,22 +98,28 @@ public class ClusterView extends JPanel { ...@@ -97,22 +98,28 @@ public class ClusterView extends JPanel {
this.setBorder(regularBorder); this.setBorder(regularBorder);
GroupLayout layout = new GroupLayout(this); GroupLayout layout = new GroupLayout(this);
layout.setHorizontalGroup(layout.createParallelGroup()
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup() .addGroup(layout.createParallelGroup(Alignment.LEADING,true)
.addComponent(title) .addComponent(title,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(clusterSize) .addComponent(clusterSize,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
) )
.addGap(6)
.addComponent(icon) .addComponent(icon)
) )
.addComponent(nodeList) .addComponent(nodeList)
); );
layout.setVerticalGroup(layout.createSequentialGroup() layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.CENTER) .addGroup(layout.createParallelGroup(Alignment.CENTER,true)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(title) .addComponent(title)
.addComponent(clusterSize) .addComponent(clusterSize)
) )
.addGap(6)
.addComponent(icon) .addComponent(icon)
) )
.addComponent(nodeList) .addComponent(nodeList)
......
...@@ -6,6 +6,7 @@ import java.awt.Rectangle; ...@@ -6,6 +6,7 @@ import java.awt.Rectangle;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.Scrollable; import javax.swing.Scrollable;
@SuppressWarnings("serial")
public class ClusterViewList extends JPanel implements Scrollable { public class ClusterViewList extends JPanel implements Scrollable {
@Override @Override
......
...@@ -231,8 +231,9 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -231,8 +231,9 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
.addComponent(opWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(opWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE)
); );
this.setLayout(layout);
scrollableContent.setLayout(scrollLayout); scrollableContent.setLayout(scrollLayout);
this.setLayout(layout);
} }
private ActionListener toggleAdvancedOptionsListener = new ActionListener() { private ActionListener toggleAdvancedOptionsListener = new ActionListener() {
......
...@@ -21,13 +21,17 @@ ...@@ -21,13 +21,17 @@
******************************************************************************/ ******************************************************************************/
package de.hhu.ba.yoshikoWrapper.swing.components; package de.hhu.ba.yoshikoWrapper.swing.components;
import static javax.swing.GroupLayout.*;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Group;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
...@@ -112,35 +116,30 @@ public class ResultPanel extends JPanel implements CytoPanelComponent{ ...@@ -112,35 +116,30 @@ public class ResultPanel extends JPanel implements CytoPanelComponent{
//Layout //Layout
GroupLayout layout = new GroupLayout(this); GroupLayout layout = new GroupLayout(this);
layout.setAutoCreateGaps(true); Group horizontalGroup = layout.createParallelGroup(Alignment.LEADING,true);
layout.setAutoCreateContainerGaps(true); Group verticalGroup = layout.createSequentialGroup();
if (result.flags.getIlpGenerated()) { layout.setHorizontalGroup(horizontalGroup);
layout.setVerticalGroup(layout.createSequentialGroup() layout.setVerticalGroup(verticalGroup);
.addComponent(marker)
.addComponent(solutionTabs)
.addComponent(destroyButton)
);
layout.setHorizontalGroup(layout.createParallelGroup() if (result.flags.getIlpGenerated()) {
.addComponent(marker) horizontalGroup.addComponent(marker,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE);
.addComponent(solutionTabs) verticalGroup.addComponent(marker,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE);
.addComponent(destroyButton)
);
} }
else {
layout.setVerticalGroup(layout.createSequentialGroup()
.addComponent(solutionTabs)
.addComponent(destroyButton)
);
layout.setHorizontalGroup(layout.createParallelGroup() horizontalGroup
.addComponent(solutionTabs) .addComponent(solutionTabs,DEFAULT_SIZE, DEFAULT_SIZE,Short.MAX_VALUE)
.addComponent(destroyButton) .addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE);
); verticalGroup
} .addComponent(solutionTabs,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
this.setLayout(layout); this.setLayout(layout);
this.setPreferredSize(new Dimension(this.getPreferredSize().width*2,this.getPreferredSize().height));
} }
public void deleteSolution() { public void deleteSolution() {
......
...@@ -24,6 +24,7 @@ package de.hhu.ba.yoshikoWrapper.swing.components; ...@@ -24,6 +24,7 @@ package de.hhu.ba.yoshikoWrapper.swing.components;
import static javax.swing.GroupLayout.DEFAULT_SIZE; import static javax.swing.GroupLayout.DEFAULT_SIZE;
import static javax.swing.GroupLayout.PREFERRED_SIZE; import static javax.swing.GroupLayout.PREFERRED_SIZE;
import java.awt.Dimension;
import java.awt.ScrollPane; import java.awt.ScrollPane;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
...@@ -32,6 +33,7 @@ import java.util.Comparator; ...@@ -32,6 +33,7 @@ import java.util.Comparator;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
import javax.swing.GroupLayout; import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.Group;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
...@@ -63,7 +65,6 @@ public class SolutionTab extends JPanel { ...@@ -63,7 +65,6 @@ public class SolutionTab extends JPanel {
//init swing components //init swing components
scrollPaneContent = new ClusterViewList(); scrollPaneContent = new ClusterViewList();
scrollPaneContent.setLayout(new BoxLayout(scrollPaneContent,BoxLayout.Y_AXIS));
//Sort cluster by size, descending //Sort cluster by size, descending
solution.cluster.sort(new Comparator<YoshikoCluster>() { solution.cluster.sort(new Comparator<YoshikoCluster>() {
...@@ -81,14 +82,29 @@ public class SolutionTab extends JPanel { ...@@ -81,14 +82,29 @@ public class SolutionTab extends JPanel {
}); });
GroupLayout scrollLayout = new GroupLayout(scrollPaneContent);
scrollLayout.setAutoCreateContainerGaps(true);
scrollLayout.setAutoCreateGaps(true);
Group horizontalGroup = scrollLayout.createParallelGroup();
Group verticalGroup = scrollLayout.createSequentialGroup();
for (YoshikoCluster c: solution.cluster) { for (YoshikoCluster c: solution.cluster) {
ClusterView clusterView = new ClusterView(c); ClusterView clusterView = new ClusterView(c);
scrollPaneContent.add(clusterView); scrollPaneContent.add(clusterView);
horizontalGroup.addComponent(clusterView);
verticalGroup.addComponent(clusterView);
} }
scrollLayout.setHorizontalGroup(horizontalGroup);
scrollLayout.setVerticalGroup(verticalGroup);
scrollPaneContent.setLayout(scrollLayout);
scrollPane = new JScrollPane(scrollPaneContent); scrollPane = new JScrollPane(scrollPaneContent);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
clusterCount = new JLabel(LocalizationManager.get("clusterFound")+" "+s.cluster.size()); clusterCount = new JLabel(LocalizationManager.get("clusterFound")+" "+s.cluster.size());
...@@ -111,13 +127,13 @@ public class SolutionTab extends JPanel { ...@@ -111,13 +127,13 @@ public class SolutionTab extends JPanel {
GroupLayout layout = new GroupLayout(this); GroupLayout layout = new GroupLayout(this);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true) layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true)
.addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(scrollPane,PREFERRED_SIZE,PREFERRED_SIZE,PREFERRED_SIZE) .addComponent(scrollPane,PREFERRED_SIZE,DEFAULT_SIZE,Short.MAX_VALUE)
.addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
); );
layout.setVerticalGroup(layout.createSequentialGroup() layout.setVerticalGroup(layout.createSequentialGroup()
.addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(clusterCount,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(scrollPane,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
.addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(createMetaGraph,DEFAULT_SIZE,DEFAULT_SIZE,DEFAULT_SIZE)
); );
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