Commit bb28c093 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Sort clusters in solution by size

parent a9abb478
/*******************************************************************************
* 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
......@@ -24,8 +24,8 @@ package de.hhu.ba.yoshikoWrapper.swing.components;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Comparator;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
......@@ -39,33 +39,50 @@ import de.hhu.ba.yoshikoWrapper.swing.SwingUtil;
@SuppressWarnings("serial")
public class SolutionTab extends JPanel {
private final JScrollPane scrollPane;
private final JPanel scrollPaneContent;
private final JLabel clusterCount;
private final JButton createMetaGraph;
private final YoshikoSolution solution;
public SolutionTab(YoshikoSolution s) {
this.solution = s;
this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
//init swing components
scrollPaneContent = new JPanel();
scrollPaneContent.setLayout(new BoxLayout(scrollPaneContent,BoxLayout.Y_AXIS));
//Sort cluster by size, descending
solution.cluster.sort(new Comparator<YoshikoCluster>() {
@Override
public int compare(YoshikoCluster o1, YoshikoCluster o2) {
if (o1.getSize() == o2.getSize()) {
return 0;
}
else if(o1.getSize() < o2.getSize()) {
return 1;
}
return -1;
}
});
for (YoshikoCluster c: solution.cluster) {
ClusterView clusterView = new ClusterView(c);
scrollPaneContent.add(clusterView);
scrollPaneContent.add(Box.createVerticalStrut(8));
}
scrollPane = new JScrollPane(scrollPaneContent);
scrollPane.setPreferredSize(new Dimension(150,400));
clusterCount = new JLabel(LocalizationManager.get("clusterFound")+" "+s.cluster.size());
createMetaGraph = new JButton(LocalizationManager.get("createMetaGraph"));
createMetaGraph.addActionListener(new ActionListener() {
......@@ -73,9 +90,9 @@ public class SolutionTab extends JPanel {
public void actionPerformed(ActionEvent e) {
solution.exportMetaGraph();
}
});
SwingUtil.addAll(this,clusterCount,scrollPane,createMetaGraph);
}
}
......@@ -2,7 +2,7 @@
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\begin{figure}
\begin{figure}[h]
\begin{tikzpicture}[node distance = 1cm]
\node [block] (datamodel) {Data Modeling};
......
No preview for this file type
......@@ -10,6 +10,7 @@
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{float}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{positioning}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment