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

[Insert generic commit message here]

parent de17a6ef
No related branches found
No related tags found
No related merge requests found
...@@ -47,12 +47,6 @@ public class YoshikoResult { ...@@ -47,12 +47,6 @@ public class YoshikoResult {
this.flags = flags; this.flags = flags;
} }
public void dispose() {
flags.delete();
originalGraph.dispose();
}
//___________SETTER GETTER_____________// //___________SETTER GETTER_____________//
/** /**
......
...@@ -66,7 +66,7 @@ public class ClusterView extends JPanel { ...@@ -66,7 +66,7 @@ public class ClusterView extends JPanel {
//SYMBOLIC LINKS //SYMBOLIC LINKS
private YoshikoCluster cluster; private final YoshikoCluster cluster;
public ClusterView(YoshikoCluster c) throws Exception { public ClusterView(YoshikoCluster c) throws Exception {
...@@ -158,4 +158,14 @@ public class ClusterView extends JPanel { ...@@ -158,4 +158,14 @@ public class ClusterView extends JPanel {
}; };
//____________SETTER GETTER ________________//
public boolean isSelected() {
return isSelected;
}
public YoshikoCluster getCluster() {
return cluster;
}
} }
...@@ -10,6 +10,7 @@ import javax.swing.Scrollable; ...@@ -10,6 +10,7 @@ import javax.swing.Scrollable;
import org.slf4j.Logger; import org.slf4j.Logger;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster;
import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger;
@SuppressWarnings("serial") @SuppressWarnings("serial")
...@@ -62,4 +63,15 @@ public class ClusterViewList extends JPanel implements Scrollable { ...@@ -62,4 +63,15 @@ public class ClusterViewList extends JPanel implements Scrollable {
return ret; return ret;
} }
public ArrayList<YoshikoCluster> getSelectedClusters() {
ArrayList<YoshikoCluster> ret = new ArrayList<YoshikoCluster>();
ArrayList<ClusterView> cv = getClusterViews();
for (ClusterView v : cv) {
if (v.isSelected()) {
ret.add(v.getCluster());
}
}
return ret;
}
} }
...@@ -78,6 +78,7 @@ NetworkAboutToBeDestroyedListener ...@@ -78,6 +78,7 @@ NetworkAboutToBeDestroyedListener
//MACRO //MACRO
//TODO: (Nächstes Leben) find a good solution with Swing that scales the panel and respects layout
private static final int HACKFIX_FIXED_WIDTH = 128+256; private static final int HACKFIX_FIXED_WIDTH = 128+256;
private final JTabbedPane tabbedPane; private final JTabbedPane tabbedPane;
...@@ -87,22 +88,31 @@ NetworkAboutToBeDestroyedListener ...@@ -87,22 +88,31 @@ NetworkAboutToBeDestroyedListener
private BasicCollapsiblePanel marker; private BasicCollapsiblePanel marker;
private final JLabel invalidLabel; private final JLabel invalidLabel;
private ArrayList<SolutionTab> solutionTabs; private final ArrayList<SolutionTab> solutionTabs;
private final YoshikoResult result; private final YoshikoResult result;
private boolean isValid;
public ResultPanel(YoshikoResult result) throws Exception { public ResultPanel(YoshikoResult result) throws Exception {
this.result = result; this.result = result;
this.isValid = true;
//Init subcomponents //Init subcomponents
invalidLabel = new JLabel(); invalidLabel = new JLabel();
tabbedPane = new JTabbedPane(); tabbedPane = new JTabbedPane();
solutionTabs = new ArrayList<SolutionTab>();
for (YoshikoSolution s : result.getSolutions()) { for (YoshikoSolution s : result.getSolutions()) {
SolutionTab tab = new SolutionTab(s); SolutionTab tab = new SolutionTab(s);
tabbedPane.add( tabbedPane.add(
LocalizationManager.get("solution")+" "+(s.getId()+1), LocalizationManager.get("solution")+" "+(s.getId()+1),
tab tab
); } );
//Save reference
solutionTabs.add(tab);
}
if (result.getFlags().getIlpGenerated()) { if (result.getFlags().getIlpGenerated()) {
//TODO: Move to MarkerPanel for better codestyle //TODO: Move to MarkerPanel for better codestyle
...@@ -163,7 +173,7 @@ NetworkAboutToBeDestroyedListener ...@@ -163,7 +173,7 @@ NetworkAboutToBeDestroyedListener
.addComponent(tabbedPane,HACKFIX_FIXED_WIDTH, PREFERRED_SIZE,Short.MAX_VALUE) .addComponent(tabbedPane,HACKFIX_FIXED_WIDTH, PREFERRED_SIZE,Short.MAX_VALUE)
.addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE); .addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE);
verticalGroup verticalGroup
.addComponent(invalidLabel,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(invalidLabel,DEFAULT_SIZE, PREFERRED_SIZE,Short.MAX_VALUE)
.addComponent(tabbedPane,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(tabbedPane,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE)
.addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE); .addComponent(destroyButton,DEFAULT_SIZE, DEFAULT_SIZE,PREFERRED_SIZE);
...@@ -195,13 +205,15 @@ NetworkAboutToBeDestroyedListener ...@@ -195,13 +205,15 @@ NetworkAboutToBeDestroyedListener
if (dialogResult != JOptionPane.YES_OPTION) { if (dialogResult != JOptionPane.YES_OPTION) {
return; return;
} }
result.dispose();
CyCore.registrar.unregisterService(this,CytoPanelComponent.class); CyCore.registrar.unregisterService(this,CytoPanelComponent.class);
removeAll(); removeAll();
super.setVisible(false); super.setVisible(false);
} }
private void invalidateResult() { private void invalidateResult() {
if (isValid) {
isValid = false;
}
invalidLabel.setText(LocalizationManager.get("invalidated")); invalidLabel.setText(LocalizationManager.get("invalidated"));
invalidLabel.setForeground(Color.RED); invalidLabel.setForeground(Color.RED);
for (SolutionTab t: solutionTabs) { for (SolutionTab t: solutionTabs) {
......
...@@ -27,12 +27,14 @@ import static javax.swing.GroupLayout.PREFERRED_SIZE; ...@@ -27,12 +27,14 @@ import static javax.swing.GroupLayout.PREFERRED_SIZE;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList;
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.GroupLayout.Group;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants; import javax.swing.ScrollPaneConstants;
...@@ -56,7 +58,7 @@ public class SolutionTab extends JPanel { ...@@ -56,7 +58,7 @@ public class SolutionTab extends JPanel {
//SWING COMPONENTS //SWING COMPONENTS
private final JScrollPane scrollPane; private final JScrollPane scrollPane;
private final ClusterViewList scrollPaneContent; private final ClusterViewList clusterViewList;
private final JLabel clusterCount; private final JLabel clusterCount;
private final JButton createClusterView; private final JButton createClusterView;
private final JButton createMetaGraph; private final JButton createMetaGraph;
...@@ -82,14 +84,14 @@ public class SolutionTab extends JPanel { ...@@ -82,14 +84,14 @@ public class SolutionTab extends JPanel {
this.solution = s; this.solution = s;
//Declaration of Swing Components //Declaration of Swing Components
scrollPaneContent = new ClusterViewList(); clusterViewList = new ClusterViewList();
for (YoshikoCluster c: solution.cluster) { for (YoshikoCluster c: solution.cluster) {
ClusterView clusterView = new ClusterView(c); ClusterView clusterView = new ClusterView(c);
scrollPaneContent.add(clusterView); clusterViewList.add(clusterView);
} }
scrollPane = new JScrollPane(scrollPaneContent); scrollPane = new JScrollPane(clusterViewList);
clusterCount = new JLabel(LocalizationManager.get("clusterFound")+" "+s.cluster.size()); clusterCount = new JLabel(LocalizationManager.get("clusterFound")+" "+s.cluster.size());
...@@ -105,9 +107,20 @@ public class SolutionTab extends JPanel { ...@@ -105,9 +107,20 @@ public class SolutionTab extends JPanel {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ArrayList<YoshikoCluster> selectedClusters = clusterViewList.getSelectedClusters();
if (selectedClusters.isEmpty()) {
JOptionPane.showMessageDialog(null,
LocalizationManager.get("optionpane_title"),
LocalizationManager.get("noClustersSelected"),
JOptionPane.INFORMATION_MESSAGE
);
return;
}
CyCore.dialogTaskManager.execute( CyCore.dialogTaskManager.execute(
new TaskIterator(1, new TaskIterator(1,
new CreateClusterViews(solution.getClusters()) new CreateClusterViews(
selectedClusters
)
) )
); );
} }
...@@ -133,7 +146,7 @@ public class SolutionTab extends JPanel { ...@@ -133,7 +146,7 @@ public class SolutionTab extends JPanel {
//Layout //Layout
scrollLayout = new GroupLayout(scrollPaneContent); scrollLayout = new GroupLayout(clusterViewList);
horizontalGroup_scrollLayout = scrollLayout.createParallelGroup(); horizontalGroup_scrollLayout = scrollLayout.createParallelGroup();
verticalGroup_scrollLayout = scrollLayout.createSequentialGroup(); verticalGroup_scrollLayout = scrollLayout.createSequentialGroup();
...@@ -144,12 +157,12 @@ public class SolutionTab extends JPanel { ...@@ -144,12 +157,12 @@ public class SolutionTab extends JPanel {
scrollLayout.setAutoCreateContainerGaps(true); scrollLayout.setAutoCreateContainerGaps(true);
scrollLayout.setAutoCreateGaps(true); scrollLayout.setAutoCreateGaps(true);
for (ClusterView v: scrollPaneContent.getClusterViews()) { for (ClusterView v: clusterViewList.getClusterViews()) {
horizontalGroup_scrollLayout.addComponent(v); horizontalGroup_scrollLayout.addComponent(v);
verticalGroup_scrollLayout.addComponent(v); verticalGroup_scrollLayout.addComponent(v);
} }
scrollPaneContent.setLayout(scrollLayout); clusterViewList.setLayout(scrollLayout);
layout = new GroupLayout(this); layout = new GroupLayout(this);
......
...@@ -44,6 +44,7 @@ icTooltip = This value is used to determine what the algorithm pays when inserti ...@@ -44,6 +44,7 @@ icTooltip = This value is used to determine what the algorithm pays when inserti
ilpMarker = ILP Properties ilpMarker = ILP Properties
incompleteResult = This run yielded no usable result! incompleteResult = This run yielded no usable result!
instance = Instance instance = Instance
invalidated = No longer valid, original graph changed!
lastInstanceGap = Gap (Current Instance): lastInstanceGap = Gap (Current Instance):
libFail = Failed to load library! Make sure you got the right file. The required version for this version of the wrapper is: libFail = Failed to load library! Make sure you got the right file. The required version for this version of the wrapper is:
libraryPanel = Library libraryPanel = Library
...@@ -55,6 +56,8 @@ noLibMessage = There is no Yoshiko Library currently loaded! You might have to s ...@@ -55,6 +56,8 @@ noLibMessage = There is no Yoshiko Library currently loaded! You might have to s
noLibTitle = Library not loaded! noLibTitle = Library not loaded!
noMappingHint = You haven't mapped the cost value to a column in your edge table.\nYoshiko runs significantly faster and generates better solutions if you map values. noMappingHint = You haven't mapped the cost value to a column in your edge table.\nYoshiko runs significantly faster and generates better solutions if you map values.
nodes = Nodes nodes = Nodes
optionpane_title = Yoshiko Info
noClustersSelected = You have not selected any clusters
notOptimal = Optimality not guaranteed notOptimal = Optimality not guaranteed
nrSolutions = Number of Solutions: nrSolutions = Number of Solutions:
operationMode = Operation Mode operationMode = Operation Mode
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment