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

More checks for invalid solutions

Made ChangeListener for Columns less strict
parent 7ea3d8d5
......@@ -32,7 +32,6 @@ import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.events.AddedEdgesListener;
import org.cytoscape.model.events.ColumnCreatedListener;
import org.cytoscape.model.events.ColumnDeletedListener;
import org.cytoscape.model.events.NetworkAddedListener;
import org.cytoscape.model.events.RemovedEdgesListener;
import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.service.util.AbstractCyActivator;
......@@ -90,6 +89,7 @@ public class CyActivator extends AbstractCyActivator {
CyCore.continuousMappingFactory = getService(context,VisualMappingFunctionFactory.class, "(mapping.type=continuous)");
CyCore.rootNetworkManager = getService(context,CyRootNetworkManager.class);
CyCore.applyVisualStyleTaskFactory = getService(context,ApplyVisualStyleTaskFactory.class);
//Not sure how to correctly infer arguments here
CyCore.renderingEngineFactory = getService(context,RenderingEngineFactory.class);
CyCore.cloneNetworkTaskFactory = getService(context,CloneNetworkTaskFactory.class);
......@@ -114,7 +114,6 @@ public class CyActivator extends AbstractCyActivator {
//Listener for Network-Changes -> Updating possible columns for mapping
NetChangeListener netChangeListener = new NetChangeListener(mainPanel.getColumnMapper());
registerService(context,netChangeListener, NetworkAddedListener.class, new Properties());
registerService(context,netChangeListener, AddedEdgesListener.class, new Properties());
registerService(context,netChangeListener, RemovedEdgesListener.class, new Properties());
registerService(context,netChangeListener, ColumnCreatedListener.class, new Properties());
......
......@@ -161,14 +161,12 @@ public class AlgorithmTask extends AbstractTask {
result = ca.run();
taskMonitor.setProgress(0.9);
if (result == null) {
throw new Exception(LocalizationManager.get("noFeasible"));
}
checkForInvalidSolutions(result);
long numberOfSolutions = result.getNumberOfSolutions();
if (numberOfSolutions == 0) {
throw new Exception(LocalizationManager.get("noFeasible"));
}
taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!"); //TODO localize
YoshikoResult yoshikoResult = new YoshikoResult();
......@@ -233,6 +231,25 @@ public class AlgorithmTask extends AbstractTask {
}
private void checkForInvalidSolutions(ClusterEditingSolutions result) throws Exception {
if (result == null) {
//There was no result object generated at all
throw new Exception(LocalizationManager.get("noFeasible"));
}
if (result.getNumberOfSolutions() == 0) {
//The result object is empty
throw new Exception(LocalizationManager.get("noFeasible"));
}
if (result.getNumberOfSolutions() == 1) {
//The result doesn't contain any clusters
if (result.getNumberOfClusters(0) == 0) {
throw new Exception(LocalizationManager.get("noFeasible"));
}
}
}
@Override
public void cancel() {
//Free C++ resources
......
......@@ -29,8 +29,6 @@ import org.cytoscape.model.events.ColumnCreatedEvent;
import org.cytoscape.model.events.ColumnCreatedListener;
import org.cytoscape.model.events.ColumnDeletedEvent;
import org.cytoscape.model.events.ColumnDeletedListener;
import org.cytoscape.model.events.NetworkAddedEvent;
import org.cytoscape.model.events.NetworkAddedListener;
import org.cytoscape.model.events.RemovedEdgesEvent;
import org.cytoscape.model.events.RemovedEdgesListener;
import org.cytoscape.session.events.SessionLoadedEvent;
......@@ -40,7 +38,6 @@ import de.hhu.ba.yoshikoWrapper.gui.ColumnMapper;
public class NetChangeListener
implements //everything
NetworkAddedListener,
AddedEdgesListener,
RemovedEdgesListener,
ColumnCreatedListener,
......@@ -56,27 +53,48 @@ SetCurrentNetworkListener
@Override
public void handleEvent(ColumnDeletedEvent e) {
columnMapper.updateValues();
if (
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultEdgeTable() ||
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultNetworkTable() ||
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultNodeTable()
)
{
columnMapper.updateValues();
}
}
@Override
public void handleEvent(ColumnCreatedEvent e) {
columnMapper.updateValues();
if (
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultEdgeTable() ||
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultNetworkTable() ||
e.getSource() == CyCore.cy.getCurrentNetwork().getDefaultNodeTable()
)
{
columnMapper.updateValues();
}
}
@Override
public void handleEvent(RemovedEdgesEvent e) {
columnMapper.updateValues();
if (
e.getSource() == CyCore.cy.getCurrentNetwork()
)
{
columnMapper.updateValues();
}
}
@Override
public void handleEvent(AddedEdgesEvent e) {
columnMapper.updateValues();
}
@Override
public void handleEvent(NetworkAddedEvent e) {
columnMapper.updateValues();
if (
e.getSource() == CyCore.cy.getCurrentNetwork()
)
{
columnMapper.updateValues();
}
}
@Override
......
......@@ -45,7 +45,7 @@ public class FormatHelper {
public static NumberFormatter getDoubleFormatter(double minValue, double maxValue) {
NumberFormat format = DecimalFormat.getInstance();
format.setMaximumFractionDigits(12);
format.setMaximumFractionDigits(Integer.MAX_VALUE);
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Double.class);
formatter.setMinimum(minValue);
......
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