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
......@@ -44,11 +44,11 @@ public class ParameterSet implements TunableValidator
//COLUMN-MAPPINGS
@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")
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")
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")
public double defaultInsertionCost = -1;
......@@ -86,40 +86,32 @@ public class ParameterSet implements TunableValidator
*/
public ParameterSet() {
ArrayList<String> columnNames = new ArrayList<String>();
ArrayList<CyColumn> columns = new ArrayList<CyColumn>();
//Only numeric columns are relevant for weight mapping
for (CyColumn col : net.getDefaultEdgeTable().getColumns()) {
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
for (CyColumn col : net.getDefaultEdgeTable().getColumns()) {
if (col.getType() == Boolean.class) {
columnNames.add(col.getName());
columns.add(col);
}
}
forbiddenColumnName = new ListSingleSelection<String>(columnNames);
permanentColumnName = new ListSingleSelection<String>(columnNames);
forbiddenColumn = new ListSingleSelection<CyColumn>(columns);
permanentColumn = new ListSingleSelection<CyColumn>(columns);
}
@Override
public ValidationState getValidationState(Appendable errMsg) {
System.out.println("DEBUG: Running VALIDATION of tunables"); //TODO: Move to logger (if it would work)
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)) {
errMsg.append("The Bitmask provided is invalid! Needs to be six bit binary (example: 011001)\n");
return ValidationState.INVALID;
......@@ -156,8 +148,11 @@ public class ParameterSet implements TunableValidator
@Override
public String toString(){
String ret = "";
String ret = "[ParameterSet]:\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
return ret;
}
......@@ -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
public void setWeightColumnName(String columnName) {
if (weightColumnName.getPossibleValues().contains(columnName)) {
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 setWeightColumn(CyColumn column) {
weightColumn.setSelectedValue(column);
}
public void setPermanentColumnName(String columnName) {
if (permanentColumnName.getPossibleValues().contains(columnName)) {
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 setPermanentColumn(CyColumn column) {
permanentColumn.setSelectedValue(column);
}
public void setForbiddenColumnName(String columnName) {
if (forbiddenColumnName.getPossibleValues().contains(columnName)) {
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 void setForbiddenColumn(CyColumn column) {
forbiddenColumn.setSelectedValue(column);
}
public String getWeightColumnName() {
return weightColumnName.getSelectedValue();
public CyColumn getWeightColumn() {
return weightColumn.getSelectedValue();
}
public String getPermanentColumnName() {
return permanentColumnName.getSelectedValue();
public CyColumn getPermanentColumn() {
return permanentColumn.getSelectedValue();
}
public String getForbiddenColumnName() {
return forbiddenColumnName.getSelectedValue();
public CyColumn getForbiddenColumn() {
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
* of this software and associated documentation files (the "Software"), to deal
......@@ -50,9 +50,14 @@ import static org.cytoscape.view.presentation.property.BasicVisualLexicon.NETWOR
public class YoshikoCluster {
/**
* The internal id used to uniquely identify the cluster
*/
private final long id;
/**
* All nodes associated with this cluster
*/
private ArrayList<CyNode> nodes;
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
* 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
* of this software and associated documentation files (the "Software"), to deal
......
......@@ -26,6 +26,9 @@ import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import org.cytoscape.model.CyColumn;
import javax.swing.GroupLayout.Alignment;
import de.hhu.ba.yoshikoWrapper.core.LocalizationManager;
......@@ -113,12 +116,6 @@ public class EditCostPanel extends JPanel {
}
//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() {
return icField.getValueAsDouble();
}
......@@ -131,8 +128,14 @@ public class EditCostPanel extends JPanel {
return columnMapper;
}
public String getWeightColumnName() {
return columnMapper.getEditingCostColumn() != null ? columnMapper.getEditingCostColumn().getName() : null;
public CyColumn getWeightColumn() {
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 {
ParameterSet ret = new ParameterSet();
ret.net = net;
ret.timeLimit = opModePanel.getTimeLimit();
ret.setWeightColumnName(ecPanel.getWeightColumnName());
ret.setPermanentColumnName(ecPanel.getPermanentColumnName());
ret.setForbiddenColumnName(ecPanel.getForbiddenColumnName());
ret.setWeightColumn(ecPanel.getWeightColumn());
ret.setPermanentColumn(ecPanel.getPermanentColumn());
ret.setForbiddenColumn(ecPanel.getForbiddenColumn());
ret.defaultInsertionCost = ecPanel.getDefaultInsertionCost();
ret.defaultDeletionCost = ecPanel.getDefaultDeletionCost();
ret.useHeuristic = opModePanel.useHeuristic();
......
......@@ -132,9 +132,9 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab
taskMonitor.setProgress(0.1);
//We identify the columns if they exist from their given names
CyColumn weightColumn = parameterSet.getWeightColumnName() != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getWeightColumnName()) : null;
CyColumn permanentColumn = parameterSet.permanentColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getPermanentColumnName()) : null;
CyColumn forbiddenColumn = parameterSet.forbiddenColumnName != null ? parameterSet.net.getDefaultEdgeTable().getColumn(parameterSet.getForbiddenColumnName()) : null;
CyColumn weightColumn = parameterSet.getWeightColumn();
CyColumn permanentColumn = parameterSet.getPermanentColumn();
CyColumn forbiddenColumn = parameterSet.getForbiddenColumn();
//Generate an c_input instance from the network
c_input = NetworkParser.parseNetwork(
......
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