Author: scooter
Date: 2012-10-11 15:28:48 -0700 (Thu, 11 Oct 2012)
New Revision: 30658
Added:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ValueUtils.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/DepictionMenus.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateNodeGraphicsTask.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreatePopupTask.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
Log:
Added MCSS calculation. Right now, it's command-only
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
2012-10-11 20:27:50 UTC (rev 30657)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ChemVizCommandHandler.java
2012-10-11 22:28:48 UTC (rev 30658)
@@ -69,6 +69,7 @@
import chemViz.model.Compound.DescriptorType;
import chemViz.tasks.CreatePopupTask;
import chemViz.tasks.CreateCompoundTableTask;
+import chemViz.tasks.CreateMCSSTask;
import chemViz.tasks.CreateNodeGraphicsTask;
import chemViz.ui.ChemInfoSettingsDialog;
@@ -91,12 +92,15 @@
LISTDESC("list descriptors",
"Return the list of available chemical descriptors",
""),
+ MCSS("mcss",
+ "Calculate the maximum common substructure of a node or group of
nodes",
+ "edge|edgelist|node|nodelist|showresult=false"),
REMOVE("remove",
"Remove 2D structures from nodes",
"network|nodelist|node"),
SHOWSTRUCTURES("show structures",
"Popup the 2D structures for a node/edge or group of
nodes/edges",
- "node|nodelist|edge|edgelist|labelattribute"),
+
"node|nodelist|edge|edgelist|labelattribute|smiles|inchi"),
SHOWTABLE("show table",
"Show the structure table for a node/edge or group of
nodes/edges",
"edge|edgelist|node|nodelist|columnlist"),
@@ -139,6 +143,7 @@
static final String NODE = "node";
static final String NODELIST = "nodelist";
static final String SELECTED = "selected";
+ static final String SHOWRESULT = "showresult";
static final String SMILES = "smiles";
static final String SMILESATTRIBUTE = "smilesattribute";
@@ -224,9 +229,24 @@
CyNetworkView view =
Cytoscape.getNetworkView(ValueUtils.getNetwork(args).getIdentifier());
// Do it!
- CreateNodeGraphicsTask cngTask = new
CreateNodeGraphicsTask(compoundList, view, dialog, false);
+ CreateNodeGraphicsTask cngTask =
CreateNodeGraphicsTask.getCustomGraphicsTask(view);
+ if (cngTask != null) {
+ cngTask.setCompoundList(compoundList);
+ cngTask.setRemove(false);
+ } else
+ cngTask = new
CreateNodeGraphicsTask(compoundList, view, dialog, false);
+
TaskManager.executeTask(cngTask,
cngTask.getDefaultTaskConfig());
+ Map<GraphObject, Compound> map = new
HashMap<GraphObject, Compound>();
+ for (Compound c: compoundList) {
+ if (!map.containsKey(c.getSource())) {
+ map.put(c.getSource(), c);
+ result.addMessage("Added compound
'"+c+"' to node '"+c.getSource()+"'");
+ }
+ }
+
+
// CALCULATE("calculate similarity",
// "Create a similarity network for the current
nodes",
// "nodelist"),
@@ -303,23 +323,89 @@
}
}
+ // MCSS("mcss",
+ // "Calculate the maximum common substructure of a
node or group of nodes",
+ // "edge|edgelist|node|nodelist|showresult=false"),
+ } else if (Command.MCSS.equals(command)) {
+ if (gObjList == null)
+ throw new RuntimeException("chemviz
"+command+": must specify node/edge or nodelist/edgelist");
+
+ List<Compound> compoundList =
ValueUtils.getCompounds(gObjList, mstring, mtype, smilesAttrList,
inchiAttrList);
+ CyAttributes attributes = Cytoscape.getNodeAttributes();
+ if (gObjList != null && (gObjList.get(0) instanceof
CyEdge))
+ attributes = Cytoscape.getEdgeAttributes();
+
+ boolean showresult = false;
+ if (args.containsKey(SHOWRESULT)) {
+ showresult =
Boolean.parseBoolean(args.get(SHOWRESULT).toString());
+ }
+
+ CreateMCSSTask mcssTask = new CreateMCSSTask(gObjList,
attributes, dialog);
+ TaskManager.executeTask(mcssTask,
mcssTask.getDefaultTaskConfig());
+
+ try {
+ while(!mcssTask.isDone()) {
+ Thread.currentThread().sleep(100);
+ }
+ } catch (Exception e) {}
+
+ String mcss = mcssTask.getMCSSSmiles();
+ result.addMessage("MCSS = "+mcss);
+ result.addResult("MCSS",mcss);
+ if (showresult) {
+ String label = "MCSS = "+mcss;
+ List<Compound> mcssList =
ValueUtils.getCompounds(null, mcss, AttriType.smiles, null, null);
+ CreatePopupTask loader = new
CreatePopupTask(mcssList, null, dialog, label, dialog.getMaxCompounds());
+ TaskManager.executeTask(loader,
loader.getDefaultTaskConfig());
+
+ if (popupTasks == null) popupTasks = new
HashMap<Integer, CreatePopupTask>();
+ result.addMessage("Showing structures: dialog
#"+popupTaskCount);
+ popupTasks.put(popupTaskCount++, loader);
+ }
+
// REMOVE("remove",
// "Remove 2D structures from nodes",
// "network|nodelist|node"),
} else if (Command.REMOVE.equals(command)) {
+ if (gObjList == null)
+ throw new RuntimeException("chemviz
"+command+": must provide node or nodelist");
+
+ // Get the network view
+ CyNetworkView view =
Cytoscape.getNetworkView(ValueUtils.getNetwork(args).getIdentifier());
+
+ // Do it!
+ CreateNodeGraphicsTask cngTask =
CreateNodeGraphicsTask.getCustomGraphicsTask(view);
+ if (cngTask != null) {
+ cngTask.setSelection(gObjList);
+ cngTask.setRemove(true);
+ } else
+ cngTask = new CreateNodeGraphicsTask(gObjList,
dialog, true);
+
+ TaskManager.executeTask(cngTask,
cngTask.getDefaultTaskConfig());
+ for (GraphObject obj: gObjList)
+ result.addMessage("Removed graphics from node
'"+obj+"'");
// SHOWSTRUCTURES("show structures",
// "Popup the 2D structures for a node or
group of nodes",
- // "node|nodelist|edge|edgelist"),
+ //
"node|nodelist|edge|edgelist|labelattribute|smiles|inchi"),
} else if (Command.SHOWSTRUCTURES.equals(command)) {
- if (gObjList == null)
- throw new RuntimeException("chemviz
"+command+": node/edge or nodelist/edgelist required");
+ if (gObjList != null && mstring != null)
+ throw new RuntimeException("chemviz
"+command+": can't have both smiles/inchi string and nodes/edges");
+ if (gObjList == null && mstring == null)
+ throw new RuntimeException("chemviz
"+command+": must have one of smiles/inchi string or nodes/edges");
String labelAttribute = null;
if (args.containsKey(LABELATTRIBUTE))
labelAttribute =
args.get(LABELATTRIBUTE).toString();
- CreatePopupTask loader = new CreatePopupTask(gObjList, dialog,
labelAttribute, dialog.getMaxCompounds());
+ CreatePopupTask loader = null;
+ if (mstring != null) {
+ List<Compound> compoundList =
ValueUtils.getCompounds(gObjList, mstring, mtype, smilesAttrList,
inchiAttrList);
+ loader = new CreatePopupTask(compoundList, null,
dialog, labelAttribute, dialog.getMaxCompounds());
+ } else {
+ List<Compound> compoundList =
ValueUtils.getCompounds(gObjList, mstring, mtype, smilesAttrList,
inchiAttrList);
+ loader = new CreatePopupTask(null, gObjList, dialog,
labelAttribute, dialog.getMaxCompounds());
+ }
TaskManager.executeTask(loader,
loader.getDefaultTaskConfig());
if (popupTasks == null) popupTasks = new
HashMap<Integer, CreatePopupTask>();
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ValueUtils.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ValueUtils.java
2012-10-11 20:27:50 UTC (rev 30657)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/commands/ValueUtils.java
2012-10-11 22:28:48 UTC (rev 30658)
@@ -122,6 +122,8 @@
// Special case for "selected" nodes
if (nodes.equals(SELECTED)) {
objList.addAll(network.getSelectedNodes());
+ } else if (nodes.equals(ALL)) {
+ objList.addAll(network.nodesList());
} else {
String[] nodeArray = nodes.split(",");
for (String str: nodeArray)
@@ -141,6 +143,8 @@
// Special case for "selected" nodes
if (edges.equals(SELECTED)) {
objList.addAll(network.getSelectedEdges());
+ } else if (edges.equals(ALL)) {
+ objList.addAll(network.edgesList());
} else {
String[] edgeArray = edges.split(",");
for (String str: edgeArray)
@@ -207,8 +211,17 @@
// Handle special case of a bare smiles string
if (mstring != null) {
- Compound c = new Compound(null, null, mstring, type,
false);
- compoundList.add(c);
+ if (objList == null || objList.size() == 0) {
+ Compound c = new Compound(null, null, mstring,
type, false);
+ compoundList.add(c);
+ } else {
+ for (GraphObject obj: objList) {
+ if (obj instanceof CyNode)
+ compoundList.add(new
Compound(obj, null, mstring, type, false));
+ else
+ compoundList.add(new
Compound(obj, null, mstring, type, false));
+ }
+ }
return compoundList;
}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/DepictionMenus.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/DepictionMenus.java
2012-10-11 20:27:50 UTC (rev 30657)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/menus/DepictionMenus.java
2012-10-11 22:28:48 UTC (rev 30658)
@@ -252,7 +252,7 @@
* @param dialog the settings dialog
*/
private void createPopup(Collection<GraphObject>selection,
ChemInfoSettingsDialog dialog) {
- CreatePopupTask loader = new CreatePopupTask(new ArrayList(selection),
dialog, null, dialog.getMaxCompounds());
+ CreatePopupTask loader = new CreatePopupTask(null, new
ArrayList(selection), dialog, null, dialog.getMaxCompounds());
TaskManager.executeTask(loader, loader.getDefaultTaskConfig());
}
Added:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
(rev 0)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateMCSSTask.java
2012-10-11 22:28:48 UTC (rev 30658)
@@ -0,0 +1,139 @@
+/*
+ Copyright (c) 2006, 2007, 2008 The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications. In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage. See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package chemViz.tasks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import giny.model.GraphObject;
+import giny.view.EdgeView;
+import giny.view.NodeView;
+
+import cytoscape.CyNode;
+import cytoscape.Cytoscape;
+import cytoscape.data.CyAttributes;
+import cytoscape.task.Task;
+
+import chemViz.model.Compound;
+import chemViz.model.Compound.AttriType;
+import chemViz.ui.ChemInfoSettingsDialog;
+import chemViz.ui.CompoundPopup;
+
+import org.openscience.cdk.Molecule;
+import org.openscience.cdk.exception.CDKException;
+import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.interfaces.IMolecule;
+import org.openscience.cdk.isomorphism.UniversalIsomorphismTester;
+import org.openscience.cdk.smiles.SmilesGenerator;
+
+
+/**
+ * The CreateCompoundsTask fetches all of the compounds defined by the
+ * object passed in its constructor and provides some methods to allow
+ * the caller to fetch the compounds when the task is complete.
+ */
+public class CreateMCSSTask extends AbstractCompoundTask {
+ List<GraphObject> objectList;
+ ChemInfoSettingsDialog dialog;
+ String type;
+ CyAttributes attributes;
+ List<Compound> compoundList;
+ IMolecule mcss = null;
+ boolean calculationComplete = false;
+
+ /**
+ * Creates the task.
+ *
+ */
+ public CreateMCSSTask(List<GraphObject> gObjList, CyAttributes attributes,
ChemInfoSettingsDialog dialog) {
+ this.objectList = gObjList;
+
+ if (gObjList.get(0) instanceof CyNode)
+ type = "node";
+ else
+ type = "edge";
+ this.dialog = dialog;
+ this.canceled = false;
+ this.attributes = attributes;
+ }
+
+ public String getTitle() {
+ return "Calculating MCSS";
+ }
+
+ public boolean isDone() {
+ return calculationComplete;
+ }
+
+ public String getMCSSSmiles() {
+ SmilesGenerator g = new SmilesGenerator();
+ return g.createSMILES(mcss);
+ }
+
+ /**
+ * Runs the task -- this will get all of the compounds, fetching the
images (if necessary) and creates the popup.
+ */
+ public void run() {
+ compoundList = getCompounds(objectList, attributes,
+
dialog.getCompoundAttributes(type,AttriType.smiles),
+
dialog.getCompoundAttributes(type,AttriType.inchi));
+
+ mcss = compoundList.get(0).getIMolecule();
+ try {
+ for (int index = 1; index < compoundList.size();
index++) {
+ List<IAtomContainer> overlap =
UniversalIsomorphismTester.getOverlaps(mcss,
compoundList.get(index).getIMolecule());
+ mcss = maximumStructure(overlap);
+ if (mcss == null) break;
+ }
+ } catch (CDKException e) {}
+ calculationComplete = true;
+ }
+
+ private IMolecule maximumStructure(List<IAtomContainer> mcsslist) {
+ int maxmcss = -99999999;
+ IAtomContainer maxac = null;
+ if (mcsslist == null || mcsslist.size() == 0) return null;
+ for (IAtomContainer a: mcsslist) {
+ if (a.getAtomCount() > maxmcss) {
+ maxmcss = a.getAtomCount();
+ maxac = a;
+ }
+ }
+ return new Molecule(maxac);
+ }
+
+ public List<Compound>getCompoundList() { return compoundList; }
+}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateNodeGraphicsTask.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateNodeGraphicsTask.java
2012-10-11 20:27:50 UTC (rev 30657)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreateNodeGraphicsTask.java
2012-10-11 22:28:48 UTC (rev 30658)
@@ -78,7 +78,7 @@
public class CreateNodeGraphicsTask extends AbstractCompoundTask
implements ActionListener,
ViewportChangeListener {
- private static HashMap<CyNetworkView, CreateNodeGraphicsTask>
customGraphicsMap = new HashMap();
+ private static HashMap<CyNetworkView, CreateNodeGraphicsTask>
customGraphicsMap = new HashMap<CyNetworkView, CreateNodeGraphicsTask>();
private static final String CustomGraphicsAttribute = "__has2DGraphics";
Collection<GraphObject> nodeSelection;
List<Compound> compoundList;
@@ -148,15 +148,12 @@
public CreateNodeGraphicsTask(List<Compound> compoundList,
CyNetworkView view,
ChemInfoSettingsDialog settingsDialog,
boolean remove) {
- this.compoundList = compoundList;
- this.nodeSelection = new ArrayList<GraphObject>();
- for (Compound c: compoundList) {
- nodeSelection.add(c.getSource());
- }
+ setCompoundList(compoundList);
this.canceled = false;
this.compoundCount = 0;
this.settingsDialog = settingsDialog;
this.removeCustomGraphics = remove;
+ this.view = view;
customGraphicsMap.put(view, this);
}
@@ -168,6 +165,13 @@
this.nodeSelection = selection;
}
+ public void setCompoundList(List<Compound> compoundList) {
+ this.compoundList = compoundList;
+ this.nodeSelection = new ArrayList<GraphObject>();
+ for (Compound c: compoundList)
+ nodeSelection.add(c.getSource());
+ }
+
public void setRemove(boolean remove) {
this.removeCustomGraphics = remove;
}
@@ -183,30 +187,6 @@
public void viewportChanged(int w, int h, double xCenter, double
yCenter, double scale) {
zoom = scale;
-/*
- // System.out.println("viewport: size="+w+"x"+h+", center =
"+xCenter+", "+yCenter+" scale = "+scale);
- CyNetworkView view = Cytoscape.getCurrentNetworkView();
- double lastScale = zoom;
- boolean needUpdate = false;
-
- zoom = scale;
-
- for (NodeView nv: viewMap.keySet()) {
- // Future -- only update nodes within the viewport
- if (!inViewport(nv, w, h, xCenter, yCenter, scale))
- continue;
- CustomGraphic cg = graphMap.get(nv);
- ((DNodeView)nv).removeCustomGraphic(cg);
- cg = drawImage(nv,viewMap.get(nv));
- if (cg == null)
- graphMap.remove(nv);
- else {
- graphMap.put(nv, cg);
- needUpdate = true;
- }
- }
- if (needUpdate) view.updateView();
-*/
}
/**
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreatePopupTask.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreatePopupTask.java
2012-10-11 20:27:50 UTC (rev 30657)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreatePopupTask.java
2012-10-11 22:28:48 UTC (rev 30658)
@@ -60,6 +60,7 @@
*/
public class CreatePopupTask extends AbstractCompoundTask {
List<GraphObject> objectList;
+ List<Compound> compoundList;
ChemInfoSettingsDialog dialog;
String labelAttribute;
CompoundPopup compoundPopup = null;
@@ -79,6 +80,7 @@
}
this.objectList = new ArrayList();
objectList.add(object);
+ this.compoundList = null;
this.dialog = dialog;
this.canceled = false;
this.maxCompounds = maxCompounds;
@@ -93,13 +95,14 @@
* @param objects the graph objects that we're creating the popup for
* @param dialog the settings dialog, which we use to pull the
attribute names that contain the compound descriptors
*/
- public CreatePopupTask(List<GraphObject>selection, ChemInfoSettingsDialog
dialog, String labelAttribute, int maxCompounds) {
+ public CreatePopupTask(List<Compound> compoundList,
List<GraphObject>selection, ChemInfoSettingsDialog dialog, String
labelAttribute, int maxCompounds) {
this.objectList = selection;
+ this.compoundList = compoundList;
this.dialog = dialog;
this.canceled = false;
this.maxCompounds = maxCompounds;
this.compoundCount = 0;
- if (labelAttribute == null)
+ if (labelAttribute == null && selection != null)
this.labelAttribute = dialog.getLabelAttribute();
else
this.labelAttribute = labelAttribute;
@@ -118,27 +121,29 @@
CyAttributes attributes = null;
String type = null;
- // Get the first object so we can do the typing
- GraphObject go = objectList.get(0);
- if (go instanceof CyNode) {
- attributes = Cytoscape.getNodeAttributes();
- type = "node";
- } else {
- attributes = Cytoscape.getEdgeAttributes();
- type = "edge";
+ if (objectList != null) {
+ // Get the first object so we can do the typing
+ GraphObject go = objectList.get(0);
+ if (go instanceof CyNode) {
+ attributes = Cytoscape.getNodeAttributes();
+ type = "node";
+ } else {
+ attributes = Cytoscape.getEdgeAttributes();
+ type = "edge";
+ }
+
+ compoundList = getCompounds(objectList, attributes,
+
dialog.getCompoundAttributes(type,AttriType.smiles),
+
dialog.getCompoundAttributes(type,AttriType.inchi));
}
-
- List<Compound> cList = getCompounds(objectList, attributes,
-
dialog.getCompoundAttributes(type,AttriType.smiles),
-
dialog.getCompoundAttributes(type,AttriType.inchi));
- if (cList.size() > 0 && !canceled) {
- if (objectList.size() == 1) {
- compoundPopup = new CompoundPopup(cList,
objectList, null);
+ if (compoundList.size() > 0 && !canceled) {
+ if (objectList != null && objectList.size() == 1) {
+ compoundPopup = new CompoundPopup(compoundList,
objectList, null);
} else {
if (labelAttribute.equals("ID"))
- compoundPopup = new
CompoundPopup(cList, objectList, type+".ID");
+ compoundPopup = new
CompoundPopup(compoundList, objectList, type+".ID");
else
- compoundPopup = new
CompoundPopup(cList, objectList, labelAttribute);
+ compoundPopup = new
CompoundPopup(compoundList, objectList, labelAttribute);
}
}
}
Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
2012-10-11 20:27:50 UTC (rev 30657)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
2012-10-11 22:28:48 UTC (rev 30658)
@@ -77,29 +77,39 @@
public CompoundPopup(List<Compound> compoundList, List<GraphObject>
objectList, String labelAttribute) {
super(Cytoscape.getDesktop());
- GraphObject go = objectList.get(0);
+
this.compoundList = compoundList;
this.imageMap = new HashMap();
this.labelAttribute = labelAttribute;
+
+ if (objectList != null && objectList.size() > 0)
+ setTitle(getObjectTitle(objectList));
+ else
+ setTitle("2D Structures");
+
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ setBackground(Color.BLACK);
+
+ addImages(400);
+ pack();
+ setVisible(true);
+ }
+
+ private String getObjectTitle(List<GraphObject> objectList) {
+ GraphObject go = objectList.get(0);
if (go instanceof CyNode) {
if (objectList.size() == 1) {
- setTitle("2D Structures for Node
"+((CyNode)go).getIdentifier());
+ return("2D Structures for Node
"+((CyNode)go).getIdentifier());
} else {
- setTitle("2D Structures for Selected Nodes");
+ return("2D Structures for Selected Nodes");
}
} else {
if (objectList.size() == 1) {
- setTitle("2D Structures for Edge
"+((CyEdge)go).getIdentifier());
+ return("2D Structures for Edge
"+((CyEdge)go).getIdentifier());
} else {
- setTitle("2D Structures for Selected Edges");
+ return("2D Structures for Selected Edges");
}
}
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setBackground(Color.BLACK);
-
- addImages(400);
- pack();
- setVisible(true);
}
public void componentHidden(ComponentEvent e) {}
@@ -140,7 +150,7 @@
attributes = Cytoscape.getEdgeAttributes();
labelAttribute = labelAttribute.substring(5);
} else
- labelAttribute = null;
+ attributes = null;
for (Compound compound: compoundList) {
// Get the image
@@ -149,9 +159,12 @@
if (labelAttribute == null) {
label = new JLabel(new ImageIcon(img));
} else {
- Object textLabel =
attributes.getAttribute(compound.getSource().getIdentifier(),labelAttribute);
- if (textLabel == null)
- textLabel =
compound.getSource().getIdentifier();
+ String textLabel = labelAttribute;
+ if (attributes != null) {
+ textLabel =
attributes.getAttribute(compound.getSource().getIdentifier(),labelAttribute).toString();
+ if (textLabel == null)
+ textLabel =
compound.getSource().getIdentifier();
+ }
label = new JLabel(textLabel.toString(), new
ImageIcon(img), JLabel.CENTER);
label.setVerticalTextPosition(JLabel.BOTTOM);
label.setHorizontalTextPosition(JLabel.CENTER);
--
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.