diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java index 1ae45b2815d7d6cb4327e50b3fff20423a0f0953..f050e37004277cd841ce03810ea04eb9c6bf0519 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java @@ -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(); } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoCluster.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoCluster.java index 6b8ebbbd3df0374f80f0c31cddc1197358aa1011..57c4563dfe84a7ce3428729fc04c6fd6a7f794e6 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoCluster.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoCluster.java @@ -1,5 +1,5 @@ /******************************************************************************* - * 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; diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java index d6af2cf7e707541e5542495db92681d8a1eedca1..16bb1f782a56f19b1f2ec3584415e3e744614d71 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java @@ -1,5 +1,5 @@ /******************************************************************************* - * 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 diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java index e86274532bc5875c091a2f3d8967c57d9a22ee71..d54fbe5149675fde7368f11e51f0f1fd2dcedec4 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoSolution.java @@ -1,5 +1,5 @@ /******************************************************************************* - * 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 diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/EditCostPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/EditCostPanel.java index b52e77685d866a4aa3c30643e17e4f4260ceae57..257ff59c002f0f2948a03a9e38e60064ae1965db 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/EditCostPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/EditCostPanel.java @@ -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; } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java index e48efbf388f40781884f32c96be856e28f1c31b2..b8277bc372c9f538336b697bbd04340ce1112096 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java @@ -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(); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java index 52d75a32a3f50dab1f7d49180be9509e29ad03e1..3d0d53fb7412c0e7905c422f419a78718ce20882 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java @@ -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(