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