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

More work on solution tab

parent 25315860
No related branches found
No related tags found
No related merge requests found
......@@ -97,7 +97,7 @@ public class YoshikoCluster {
/**
* Attempt to select the nodes belonging to this cluster in the original Graph given that they still exist
*/
public void select() {
public void highlightInOriginalGraph() {
try {
List<CyRow> allRows = originalGraph.getDefaultNodeTable().getAllRows();
for (CyRow r: allRows) {
......@@ -114,16 +114,17 @@ public class YoshikoCluster {
}
public void applyImage(JLabel label, int width, int height) {
public void applyImage(JLabel label, int width, int height) throws Exception {
if (net == null) {
return;
throw new Exception("Can't have an image without having a network associated");
}
if (img != null) {
getImage(width,height,label);
label.setIcon(new ImageIcon(img));
return;
}
else {
getImage(width,height,label);
}
}
......@@ -160,7 +161,6 @@ public class YoshikoCluster {
public void run() {
img = renderingEngine.createImage(width,height);
label.setIcon(new ImageIcon(img));
renderingEngine.dispose();
view.dispose();
}
......
......@@ -22,14 +22,17 @@
package de.hhu.ba.yoshikoWrapper.swing.components;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.GroupLayout.Alignment;
import javax.swing.border.Border;
import org.cytoscape.model.CyNode;
......@@ -43,12 +46,14 @@ import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
@SuppressWarnings("serial")
public class ClusterView extends JPanel {
private final static int CLUSTER_ICON_SIZE = 128;
private final JLabel title;
private final JLabel clusterSize;
private final JLabel icon;
private final BasicCollapsiblePanel nodeList;
private final Border regularBorder = BorderFactory.createLineBorder(Color.GRAY,1);
private final Border regularBorder = BorderFactory.createLineBorder(Color.GRAY,3);
private final Border highlightBorder = BorderFactory.createLineBorder(GraphicsLoader.yoshikoGreen,3);
private final Border selectedBorder = BorderFactory.createLineBorder(Color.BLUE,3);
......@@ -59,18 +64,18 @@ public class ClusterView extends JPanel {
*/
private YoshikoCluster cluster;
public ClusterView(YoshikoCluster c) {
public ClusterView(YoshikoCluster c) throws Exception {
this.cluster = c;
//Swing init
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
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));
cluster.applyImage(icon,128, 128);
cluster.applyImage(icon,CLUSTER_ICON_SIZE, CLUSTER_ICON_SIZE);
SwingUtil.addAll(this,title,clusterSize,icon);
this.add(Box.createVerticalStrut(4));
......@@ -89,9 +94,32 @@ public class ClusterView extends JPanel {
this.add(nodeList);
this.addMouseListener(mouseListener);
this.setBorder(regularBorder);
GroupLayout layout = new GroupLayout(this);
layout.setHorizontalGroup(layout.createParallelGroup()
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(title)
.addComponent(clusterSize)
)
.addComponent(icon)
)
.addComponent(nodeList)
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(Alignment.CENTER)
.addGroup(layout.createSequentialGroup()
.addComponent(title)
.addComponent(clusterSize)
)
.addComponent(icon)
)
.addComponent(nodeList)
);
this.setLayout(layout);
}
private MouseListener mouseListener = new MouseListener() {
......@@ -101,7 +129,7 @@ public class ClusterView extends JPanel {
@Override
public void mousePressed(MouseEvent e) {
cluster.select();
cluster.highlightInOriginalGraph();
}
@Override
......
package de.hhu.ba.yoshikoWrapper.swing.components;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JPanel;
import javax.swing.Scrollable;
public class ClusterViewList extends JPanel implements Scrollable {
@Override
public Dimension getPreferredScrollableViewportSize() {
return this.getPreferredSize();
}
@Override
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
return 16;
}
@Override
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
return 16;
}
@Override
public boolean getScrollableTracksViewportWidth() {
return true;
}
@Override
public boolean getScrollableTracksViewportHeight() {
return false;
}
}
......@@ -59,7 +59,7 @@ public class ResultPanel extends JPanel implements CytoPanelComponent{
private final YoshikoResult result;
public ResultPanel(YoshikoResult result) {
public ResultPanel(YoshikoResult result) throws Exception {
this.result = result;
......@@ -159,7 +159,7 @@ public class ResultPanel extends JPanel implements CytoPanelComponent{
super.setVisible(false);
}
private void addSolutionTab(YoshikoSolution s) {
private void addSolutionTab(YoshikoSolution s) throws Exception {
SolutionTab tab = new SolutionTab(s);
solutionTabs.add(
LocalizationManager.get("solution")+" "+(s.getId()+1),
......
......@@ -21,16 +21,22 @@
******************************************************************************/
package de.hhu.ba.yoshikoWrapper.swing.components;
import java.awt.Dimension;
import static javax.swing.GroupLayout.DEFAULT_SIZE;
import static javax.swing.GroupLayout.PREFERRED_SIZE;
import java.awt.ScrollPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Comparator;
import javax.swing.BoxLayout;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import org.cytoscape.work.TaskIterator;
......@@ -45,19 +51,18 @@ import de.hhu.ba.yoshikoWrapper.tasks.CreateMetaGraphTask;
public class SolutionTab extends JPanel {
private final JScrollPane scrollPane;
private final JPanel scrollPaneContent;
private final ClusterViewList scrollPaneContent;
private final JLabel clusterCount;
private final JButton createMetaGraph;
private final YoshikoSolution solution;
public SolutionTab(YoshikoSolution s) {
public SolutionTab(YoshikoSolution s) throws Exception {
this.solution = s;
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
//init swing components
scrollPaneContent = new JPanel();
scrollPaneContent = new ClusterViewList();
scrollPaneContent.setLayout(new BoxLayout(scrollPaneContent,BoxLayout.Y_AXIS));
//Sort cluster by size, descending
......@@ -83,7 +88,7 @@ public class SolutionTab extends JPanel {
scrollPane = new JScrollPane(scrollPaneContent);
scrollPane.setPreferredSize(new Dimension(150,400));
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
clusterCount = new JLabel(LocalizationManager.get("clusterFound")+" "+s.cluster.size());
......@@ -101,6 +106,21 @@ public class SolutionTab extends JPanel {
});
SwingUtil.addAll(this,clusterCount,scrollPane,createMetaGraph);
//Layout
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(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)
);
this.setLayout(layout);
}
}
......@@ -47,8 +47,6 @@ public class CreateMetaGraphTask extends AbstractTask {
//Add nodes
for (YoshikoCluster c: solution.getCluster()) {
CyNode clusterNode = metaGraph.addNode();
CySubNetwork subnet = c.getSubNetwork();
CyCore.networkManager.addNetwork(subnet);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment