Author: arman
Date: 2008-09-25 10:28:43 -0700 (Thu, 25 Sep 2008)
New Revision: 14962
Modified:
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/task/ScoreSimilarComponentsTask.java
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityBasedMergeDialog.form
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityBasedMergeDialog.java
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityDetailsDialog.java
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/util/MatchScore.java
Log:
a couple of bug fixes
Modified:
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/task/ScoreSimilarComponentsTask.java
===================================================================
---
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/task/ScoreSimilarComponentsTask.java
2008-09-24 23:18:15 UTC (rev 14961)
+++
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/task/ScoreSimilarComponentsTask.java
2008-09-25 17:28:43 UTC (rev 14962)
@@ -105,6 +105,7 @@
CyAttributes attrs = type.getAttributes();
double cumulativeScore = 1;
+ Map<String, String> matchedAttributes = new HashMap<String, String>();
for(Criteria criteria: criteriaList) {
boolean isMatch = false;
@@ -130,15 +131,18 @@
if( ((List) value2).contains(value1) )
isMatch = true;
} else {
- if( value1.toString().equalsIgnoreCase(value2.toString()) )
+ if( (value1.toString().length() > 0 &&
value2.toString().length() > 0) &&
+ value1.toString().equalsIgnoreCase(value2.toString()) )
isMatch = true;
}
- if(isMatch)
+ if(isMatch) {
cumulativeScore *= (1.0 - criteria.importance);
+ matchedAttributes.put(criteria.attribute1,
criteria.attribute2);
+ }
}
- return new MatchScore(type, 1.0 - cumulativeScore, id1, id2);
+ return new MatchScore(type, 1.0 - cumulativeScore, id1, id2,
matchedAttributes);
}
public void halt() {
Modified:
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityBasedMergeDialog.form
===================================================================
---
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityBasedMergeDialog.form
2008-09-24 23:18:15 UTC (rev 14961)
+++
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityBasedMergeDialog.form
2008-09-25 17:28:43 UTC (rev 14962)
@@ -259,12 +259,15 @@
</constraints>
<properties>
<preferredSize width="454" height="20"/>
+ <verticalScrollBarPolicy value="22"/>
</properties>
<border type="none"/>
<children>
<component id="b9762" class="javax.swing.JTable"
binding="criteriasTable">
<constraints/>
- <properties/>
+ <properties>
+ <fillsViewportHeight value="true"/>
+ </properties>
</component>
</children>
</scrollpane>
Modified:
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityBasedMergeDialog.java
===================================================================
---
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityBasedMergeDialog.java
2008-09-24 23:18:15 UTC (rev 14961)
+++
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityBasedMergeDialog.java
2008-09-25 17:28:43 UTC (rev 14962)
@@ -154,8 +154,8 @@
updateMatchesTable();
}
});
+ updateMatchesTable();
-
for (ComponentType ct : ComponentType.values())
componentTypes.add(ct.toString());
componentTypeComboBox.setModel(new
DefaultComboBoxModel(componentTypes.toArray()));
@@ -191,6 +191,7 @@
updateCriteriasTable();
}
});
+ updateCriteriasTable();
matchesTable.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
@@ -220,13 +221,18 @@
String[][] tableData = new String[criteriaList.size()][];
DecimalFormat df = new DecimalFormat("###");
- int count = 0;
- for (Criteria criteria : criteriaList) {
- String[] aRow = {criteria.type.toString(),
- criteria.attribute1,
- criteria.attribute2,
- df.format(criteria.importance * MAX_SCORE) + "/" +
MAX_SCORE};
- tableData[count++] = aRow;
+ if (criteriaList.isEmpty()) {
+ tableHeaders = new String[]{""};
+ tableData = new String[][]{{"No criterieas."}};
+ } else {
+ int count = 0;
+ for (Criteria criteria : criteriaList) {
+ String[] aRow = {criteria.type.toString(),
+ criteria.attribute1,
+ criteria.attribute2,
+ df.format(criteria.importance * MAX_SCORE) + "/" +
MAX_SCORE};
+ tableData[criteriaList.size() - ++count] = aRow;
+ }
}
criteriasTable.setModel(new DefaultTableModel(tableData, tableHeaders)
{
@@ -334,9 +340,8 @@
jTaskConfig.displayStatus(true);
jTaskConfig.setAutoDispose(false);
+ dispose();
TaskManager.executeTask(task, jTaskConfig);
-
- dispose();
}
private void onCancel() {
@@ -604,6 +609,7 @@
panel9.add(deleteCriteriaButton, gbc);
final JScrollPane scrollPane1 = new JScrollPane();
scrollPane1.setPreferredSize(new Dimension(454, 20));
+ scrollPane1.setVerticalScrollBarPolicy(22);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
@@ -612,6 +618,7 @@
gbc.fill = GridBagConstraints.BOTH;
panel9.add(scrollPane1, gbc);
criteriasTable = new JTable();
+ criteriasTable.setFillsViewportHeight(true);
scrollPane1.setViewportView(criteriasTable);
final JPanel panel10 = new JPanel();
panel10.setLayout(new GridBagLayout());
Modified:
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityDetailsDialog.java
===================================================================
---
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityDetailsDialog.java
2008-09-24 23:18:15 UTC (rev 14961)
+++
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/ui/SimilarityDetailsDialog.java
2008-09-25 17:28:43 UTC (rev 14962)
@@ -34,9 +34,12 @@
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
import java.awt.event.*;
import java.awt.*;
import java.text.DecimalFormat;
+import java.util.Collection;
+import java.util.ArrayList;
import cytoscape.data.CyAttributes;
import cytoscape.data.Semantics;
@@ -81,11 +84,25 @@
df.format(matchScore.score *
SimilarityBasedMergeDialog.MAX_SCORE)
+ " / " + SimilarityBasedMergeDialog.MAX_SCORE);
- tree1.setModel(new
DefaultTreeModel(createTreeFromComponent(matchScore.type, matchScore.id1)));
- tree2.setModel(new
DefaultTreeModel(createTreeFromComponent(matchScore.type, matchScore.id2)));
+ ArrayList<TreePath> selectedPaths = new ArrayList<TreePath>();
+ TreeNode rootNode = createTreeFromComponent(matchScore.type,
+ matchScore.id1,
+ matchScore.matchedAttributesMap.keySet(),
+ selectedPaths);
+ tree1.setModel(new DefaultTreeModel(rootNode));
+ tree1.setSelectionPaths(selectedPaths.toArray(new
TreePath[selectedPaths.size()]));
+ selectedPaths.clear();
+
+ rootNode = createTreeFromComponent(matchScore.type,
+ matchScore.id2,
+ matchScore.matchedAttributesMap.values(),
+ selectedPaths);
+ tree2.setModel(new DefaultTreeModel(rootNode));
+ tree2.setSelectionPaths(selectedPaths.toArray(new
TreePath[selectedPaths.size()]));
}
- private TreeNode createTreeFromComponent(ComponentType type, String id) {
+ private TreeNode createTreeFromComponent(ComponentType type, String id,
Collection<String> toBeHighlighted,
+ ArrayList<TreePath>
selectedPaths) {
CyAttributes attrs = type.getAttributes();
String cName = attrs.getStringAttribute(id, Semantics.CANONICAL_NAME);
@@ -94,9 +111,13 @@
if (!attrs.hasAttribute(id, attrName))
continue;
+
DefaultMutableTreeNode subRootNode = new
DefaultMutableTreeNode(attrName);
rootNode.add(subRootNode);
+ if (toBeHighlighted.contains(attrName))
+ selectedPaths.add(new TreePath(subRootNode.getPath()));
+
Object value = attrs.getAttribute(id, attrName);
if (value instanceof List) {
for (Object subvalue : ((List) value).getItems()) {
Modified:
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/util/MatchScore.java
===================================================================
---
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/util/MatchScore.java
2008-09-24 23:18:15 UTC (rev 14961)
+++
csplugins/trunk/soc/arman/SimilarityBasedMergePlugin/src/org/biyoenformatik/cytoscape_merge/util/MatchScore.java
2008-09-25 17:28:43 UTC (rev 14962)
@@ -27,16 +27,20 @@
package org.biyoenformatik.cytoscape_merge.util;
+import java.util.Map;
+
public class MatchScore implements Comparable {
public Double score = .0;
public ComponentType type;
public String id1, id2;
+ public Map<String, String> matchedAttributesMap;
- public MatchScore(ComponentType type, double score, String id1, String
id2) {
+ public MatchScore(ComponentType type, double score, String id1, String
id2, Map<String, String> matchedAttributes) {
this.type = type;
this.score = score;
this.id1 = id1;
this.id2 = id2;
+ this.matchedAttributesMap = matchedAttributes;
}
public int compareTo(Object o) {
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en
-~----------~----~----~----~------~----~------~--~---