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

More elegant handling of CyColumn tunable, removed workaround via String completely

Updated some headers, some Javadoc
parent 335c0242
No related branches found
No related tags found
No related merge requests found
...@@ -44,11 +44,11 @@ public class ParameterSet implements TunableValidator ...@@ -44,11 +44,11 @@ public class ParameterSet implements TunableValidator
//COLUMN-MAPPINGS //COLUMN-MAPPINGS
@Tunable(description="A column in the edge table containing weights", context="nogui") @Tunable(description="A column in the edge table containing weights", context="nogui")
public ListSingleSelection<String> weightColumnName = null; public ListSingleSelection<CyColumn> weightColumn = null;
@Tunable(description="A column containing boolean entries for edges that are to be treated as permanent",context="nogui") @Tunable(description="A column containing boolean entries for edges that are to be treated as permanent",context="nogui")
public ListSingleSelection<String> permanentColumnName = null; public ListSingleSelection<CyColumn> permanentColumn = null;
@Tunable(description="A column containing boolean entries for edges that are to be treated as forbidden",context="nogui") @Tunable(description="A column containing boolean entries for edges that are to be treated as forbidden",context="nogui")
public ListSingleSelection<String> forbiddenColumnName = null; public ListSingleSelection<CyColumn> forbiddenColumn = null;
@Tunable(description="The default insertion cost that is to be used for non-existing edges",context="nogui") @Tunable(description="The default insertion cost that is to be used for non-existing edges",context="nogui")
public double defaultInsertionCost = -1; public double defaultInsertionCost = -1;
...@@ -86,40 +86,32 @@ public class ParameterSet implements TunableValidator ...@@ -86,40 +86,32 @@ public class ParameterSet implements TunableValidator
*/ */
public ParameterSet() { public ParameterSet() {
ArrayList<String> columnNames = new ArrayList<String>(); ArrayList<CyColumn> columns = new ArrayList<CyColumn>();
//Only numeric columns are relevant for weight mapping //Only numeric columns are relevant for weight mapping
for (CyColumn col : net.getDefaultEdgeTable().getColumns()) { for (CyColumn col : net.getDefaultEdgeTable().getColumns()) {
if (Number.class.isAssignableFrom(col.getType())) { if (Number.class.isAssignableFrom(col.getType())) {
columnNames.add(col.getName()); columns.add(col);
} }
} }
weightColumnName = new ListSingleSelection<String>(columnNames); weightColumn = new ListSingleSelection<CyColumn>(columns);
columnNames = new ArrayList<String>(); columns.clear();
//Only boolean columns are relevant for forbidden/permanent mapping //Only boolean columns are relevant for forbidden/permanent mapping
for (CyColumn col : net.getDefaultEdgeTable().getColumns()) { for (CyColumn col : net.getDefaultEdgeTable().getColumns()) {
if (col.getType() == Boolean.class) { if (col.getType() == Boolean.class) {
columnNames.add(col.getName()); columns.add(col);
} }
} }
forbiddenColumnName = new ListSingleSelection<String>(columnNames); forbiddenColumn = new ListSingleSelection<CyColumn>(columns);
permanentColumnName = new ListSingleSelection<String>(columnNames); permanentColumn = new ListSingleSelection<CyColumn>(columns);
} }
@Override @Override
public ValidationState getValidationState(Appendable errMsg) { public ValidationState getValidationState(Appendable errMsg) {
System.out.println("DEBUG: Running VALIDATION of tunables"); //TODO: Move to logger (if it would work) System.out.println("DEBUG: Running VALIDATION of tunables"); //TODO: Move to logger (if it would work)
try { try {
if (net!= null) {
//Verify column validity
CyColumn weightColumn = net.getDefaultEdgeTable().getColumn(weightColumnName.getSelectedValue());
if (weightColumn == null) {
errMsg.append("Could not find a column named: "+weightColumnName+"\n");
return ValidationState.INVALID;
}
}
if (!checkBitmask(reductionRulesBitMask)) { if (!checkBitmask(reductionRulesBitMask)) {
errMsg.append("The Bitmask provided is invalid! Needs to be six bit binary (example: 011001)\n"); errMsg.append("The Bitmask provided is invalid! Needs to be six bit binary (example: 011001)\n");
return ValidationState.INVALID; return ValidationState.INVALID;
...@@ -156,8 +148,11 @@ public class ParameterSet implements TunableValidator ...@@ -156,8 +148,11 @@ public class ParameterSet implements TunableValidator
@Override @Override
public String toString(){ public String toString(){
String ret = ""; String ret = "[ParameterSet]:\n";
ret += "Target Cluster Count: "+clusterCount+"\n"; ret += "Target Cluster Count: "+clusterCount+"\n";
ret += "Weight mapped to column: "+(weightColumn.getSelectedValue() != null ? weightColumn.getSelectedValue().getName() : "[NONE]")+"\n";
ret += "Permanent edges mapped to column: "+(permanentColumn.getSelectedValue() != null ? permanentColumn.getSelectedValue().getName() : "[NONE]")+"\n";
ret += "Forbidden edges mapped to column: "+(forbiddenColumn.getSelectedValue() != null ? forbiddenColumn.getSelectedValue().getName() : "[NONE]")+"\n";
//TODO //TODO
return ret; return ret;
} }
...@@ -166,46 +161,28 @@ public class ParameterSet implements TunableValidator ...@@ -166,46 +161,28 @@ public class ParameterSet implements TunableValidator
//TODO: Code Redundancy, might be smart to insert the three columns into some sort of super structure and then remove the redundant setters/getters, pass column type as argument //TODO: Code Redundancy, might be smart to insert the three columns into some sort of super structure and then remove the redundant setters/getters, pass column type as argument
public void setWeightColumnName(String columnName) { public void setWeightColumn(CyColumn column) {
if (weightColumnName.getPossibleValues().contains(columnName)) { weightColumn.setSelectedValue(column);
weightColumnName.setSelectedValue(columnName);
}
else {
//Attempting to set a column that is not part of the possible values
//TODO: Output debug/warning if Cytoscape logger will eventually work
}
} }
public void setPermanentColumnName(String columnName) { public void setPermanentColumn(CyColumn column) {
if (permanentColumnName.getPossibleValues().contains(columnName)) { permanentColumn.setSelectedValue(column);
permanentColumnName.setSelectedValue(columnName);
}
else {
//Attempting to set a column that is not part of the possible values
//TODO: Output debug/warning if Cytoscape logger will eventually work
}
} }
public void setForbiddenColumnName(String columnName) { public void setForbiddenColumn(CyColumn column) {
if (forbiddenColumnName.getPossibleValues().contains(columnName)) { forbiddenColumn.setSelectedValue(column);
forbiddenColumnName.setSelectedValue(columnName);
}
else {
//Attempting to set a column that is not part of the possible values
//TODO: Output debug/warning if Cytoscape logger will eventually work
}
} }
public String getWeightColumnName() { public CyColumn getWeightColumn() {
return weightColumnName.getSelectedValue(); return weightColumn.getSelectedValue();
} }
public String getPermanentColumnName() { public CyColumn getPermanentColumn() {
return permanentColumnName.getSelectedValue(); return permanentColumn.getSelectedValue();
} }
public String getForbiddenColumnName() { public CyColumn getForbiddenColumn() {
return forbiddenColumnName.getSelectedValue(); return forbiddenColumn.getSelectedValue();
} }
} }
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2017 Philipp Spohr * Copyright (C) 2018 Philipp Spohr
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
...@@ -50,9 +50,14 @@ import static org.cytoscape.view.presentation.property.BasicVisualLexicon.NETWOR ...@@ -50,9 +50,14 @@ import static org.cytoscape.view.presentation.property.BasicVisualLexicon.NETWOR
public class YoshikoCluster { public class YoshikoCluster {
/**
* The internal id used to uniquely identify the cluster
*/
private final long id; private final long id;
/**
* All nodes associated with this cluster
*/
private ArrayList<CyNode> nodes; private ArrayList<CyNode> nodes;
private Image img; private Image img;
......
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2017 Philipp Spohr * Copyright (C) 2018 Philipp Spohr
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
......
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2017 Philipp Spohr * Copyright (C) 2018 Philipp Spohr
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
......
...@@ -26,6 +26,9 @@ import javax.swing.GroupLayout; ...@@ -26,6 +26,9 @@ import javax.swing.GroupLayout;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JSeparator; import javax.swing.JSeparator;
import org.cytoscape.model.CyColumn;
import javax.swing.GroupLayout.Alignment; import javax.swing.GroupLayout.Alignment;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
...@@ -113,12 +116,6 @@ public class EditCostPanel extends JPanel { ...@@ -113,12 +116,6 @@ public class EditCostPanel extends JPanel {
} }
//SETTER / GETTER //SETTER / GETTER
public String getPermanentColumnName() {
return columnMapper.getPermanentColumn() != null ? columnMapper.getPermanentColumn().getName() : null; }
public String getForbiddenColumnName() {
return columnMapper.getForbiddenColumn() != null ? columnMapper.getForbiddenColumn().getName() : null; }
public double getDefaultInsertionCost() { public double getDefaultInsertionCost() {
return icField.getValueAsDouble(); return icField.getValueAsDouble();
} }
...@@ -131,8 +128,14 @@ public class EditCostPanel extends JPanel { ...@@ -131,8 +128,14 @@ public class EditCostPanel extends JPanel {
return columnMapper; return columnMapper;
} }
public String getWeightColumnName() { public CyColumn getWeightColumn() {
return columnMapper.getEditingCostColumn() != null ? columnMapper.getEditingCostColumn().getName() : null; return columnMapper.getEditingCostColumn() != null ? columnMapper.getEditingCostColumn() : null;
} }
public CyColumn getPermanentColumn() {
return columnMapper.getPermanentColumn() != null ? columnMapper.getPermanentColumn() : null; }
public CyColumn getForbiddenColumn() {
return columnMapper.getForbiddenColumn() != null ? columnMapper.getForbiddenColumn(): null; }
} }
...@@ -346,9 +346,9 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ...@@ -346,9 +346,9 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
ParameterSet ret = new ParameterSet(); ParameterSet ret = new ParameterSet();
ret.net = net; ret.net = net;
ret.timeLimit = opModePanel.getTimeLimit(); ret.timeLimit = opModePanel.getTimeLimit();
ret.setWeightColumnName(ecPanel.getWeightColumnName()); ret.setWeightColumn(ecPanel.getWeightColumn());
ret.setPermanentColumnName(ecPanel.getPermanentColumnName()); ret.setPermanentColumn(ecPanel.getPermanentColumn());
ret.setForbiddenColumnName(ecPanel.getForbiddenColumnName()); ret.setForbiddenColumn(ecPanel.getForbiddenColumn());
ret.defaultInsertionCost = ecPanel.getDefaultInsertionCost(); ret.defaultInsertionCost = ecPanel.getDefaultInsertionCost();
ret.defaultDeletionCost = ecPanel.getDefaultDeletionCost(); ret.defaultDeletionCost = ecPanel.getDefaultDeletionCost();
ret.useHeuristic = opModePanel.useHeuristic(); ret.useHeuristic = opModePanel.useHeuristic();
......
...@@ -132,9 +132,9 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab ...@@ -132,9 +132,9 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab
taskMonitor.setProgress(0.1); taskMonitor.setProgress(0.1);
//We identify the columns if they exist from their given names //We identify the columns if they exist from their given names
CyColumn weightColumn = parameterSet.getWeightColumnName() != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getWeightColumnName()) : null; CyColumn weightColumn = parameterSet.getWeightColumn();
CyColumn permanentColumn = parameterSet.permanentColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getPermanentColumnName()) : null; CyColumn permanentColumn = parameterSet.getPermanentColumn();
CyColumn forbiddenColumn = parameterSet.forbiddenColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getForbiddenColumnName()) : null; CyColumn forbiddenColumn = parameterSet.getForbiddenColumn();
//Generate an c_input instance from the network //Generate an c_input instance from the network
c_input = NetworkParser.parseNetwork( c_input = NetworkParser.parseNetwork(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment