Author: scooter
Date: 2010-02-12 13:27:04 -0800 (Fri, 12 Feb 2010)
New Revision: 19323
Modified:
csplugins/trunk/ucsf/scooter/chemViz/build.xml
csplugins/trunk/ucsf/scooter/chemViz/resources/plugin.props
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ChemViz.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreatePopupTask.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/ChemInfoSettingsDialog.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/TableMouseAdapter.java
Log:
Updated to support new features for structure popup
Modified: csplugins/trunk/ucsf/scooter/chemViz/build.xml
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/build.xml 2010-02-12 20:53:55 UTC
(rev 19322)
+++ csplugins/trunk/ucsf/scooter/chemViz/build.xml 2010-02-12 21:27:04 UTC
(rev 19323)
@@ -113,7 +113,7 @@
</copy>
<jar jarfile="${build.dir}/chemViz.jar">
<manifest>
- <attribute name="Cytoscape-Plugin" value="chemViz.ChemVizPlugin" />
+ <attribute name="Cytoscape-Plugin" value="chemViz.ChemViz" />
</manifest>
<fileset dir="${build.dir}/classes" />
<fileset dir="${build.dir}/classes/lib"/>
Modified: csplugins/trunk/ucsf/scooter/chemViz/resources/plugin.props
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/resources/plugin.props 2010-02-12
20:53:55 UTC (rev 19322)
+++ csplugins/trunk/ucsf/scooter/chemViz/resources/plugin.props 2010-02-12
21:27:04 UTC (rev 19323)
@@ -13,10 +13,10 @@
pluginDescription=This plugin provides a variety of cheminformatics
descriptors and visualizations
# Plugin version number, this must be two numbers separated by a decimlal.
Ex. 0.2, 14.03
-pluginVersion=1.0
+pluginVersion=1.1
# Compatible Cytoscape version
-cytoscapeVersion=2.6.3
+cytoscapeVersion=2.6.3,2.7
# Category, use one of the categories listed on the website or create your own
pluginCategory=Analysis
Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ChemViz.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ChemViz.java
2010-02-12 20:53:55 UTC (rev 19322)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ChemViz.java
2010-02-12 21:27:04 UTC (rev 19323)
@@ -105,15 +105,6 @@
menu.addMenuListener(new ChemVizMenu(systemProps,
settingsDialog));
pluginMenu.add(menu);
-
- // See if we've already got a network that has custom
graphics
- if
(CreateNodeGraphicsTask.hasCustomGraphics(Cytoscape.getCurrentNetwork())) {
- List<Node> selection =
-
CreateNodeGraphicsTask.getCustomGraphicsNodes(Cytoscape.getCurrentNetworkView());
-
- CreateNodeGraphicsTask loader = new
CreateNodeGraphicsTask(selection, settingsDialog, false);
- TaskManager.executeTask(loader,
loader.getDefaultTaskConfig());
- }
} catch (Exception e) {
logger.error("Unable to initialize menus:
"+e.getMessage(), e);
}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreatePopupTask.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreatePopupTask.java
2010-02-12 20:53:55 UTC (rev 19322)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/tasks/CreatePopupTask.java
2010-02-12 21:27:04 UTC (rev 19323)
@@ -61,6 +61,7 @@
public class CreatePopupTask extends AbstractCompoundTask {
List<GraphObject> objectList;
ChemInfoSettingsDialog dialog;
+ String labelAttribute;
/**
* Creates the task.
@@ -81,6 +82,7 @@
this.canceled = false;
this.maxCompounds = maxCompounds;
this.compoundCount = 0;
+ this.labelAttribute = dialog.getLabelAttribute();
}
/**
@@ -95,6 +97,7 @@
this.canceled = false;
this.maxCompounds = maxCompounds;
this.compoundCount = 0;
+ this.labelAttribute = dialog.getLabelAttribute();
}
public String getTitle() {
@@ -122,7 +125,11 @@
dialog.getCompoundAttributes(type,AttriType.smiles),
dialog.getCompoundAttributes(type,AttriType.inchi));
if (cList.size() > 0 && !canceled) {
- CompoundPopup popup = new CompoundPopup(cList, objectList);
+ if (objectList.size() == 1) {
+ CompoundPopup popup = new CompoundPopup(cList,
objectList, null);
+ } else {
+ CompoundPopup popup = new CompoundPopup(cList,
objectList, labelAttribute);
+ }
}
}
}
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/ChemInfoSettingsDialog.java
===================================================================
---
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/ChemInfoSettingsDialog.java
2010-02-12 20:53:55 UTC (rev 19322)
+++
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/ChemInfoSettingsDialog.java
2010-02-12 21:27:04 UTC (rev 19323)
@@ -99,6 +99,7 @@
DepictionPositions.MIDDLELEFT};
private static List<String> smilesAttributes = null;
private static List<String> inCHIAttributes = null;
+ private static List<String> possibleAttributes = null;
private ChemInfoProperties properties;
private JPanel tunablePanel;
private int maxCompounds = 0;
@@ -106,6 +107,7 @@
private boolean showHyd = false;
private int labelPositionIndex = 0;
private int nodeStructureSize = 100;
+ private String labelAttribute = "ID";
public ChemInfoSettingsDialog() {
super(Cytoscape.getDesktop(), "ChemViz Plugin Settings Dialog",
false);
@@ -215,6 +217,12 @@
labelPositionIndex = ((Integer)t.getValue()).intValue();
}
+ t = properties.get("labelAttribute");
+ if ((t != null) && (t.valueChanged() || force)) {
+ int index = ((Integer)t.getValue()).intValue();
+ labelAttribute = possibleAttributes.get(index);
+ }
+
/*
t = properties.get("showHyd");
if ((t != null) && (t.valueChanged() || force)) {
@@ -244,7 +252,7 @@
if (nodeSet == null)
return true;
- // We we know all of the attributes we're interested in -- see
if these objects have any of them
+ // We know all of the attributes we're interested in -- see if
these objects have any of them
for (CyNode node: nodeSet) {
for (String attribute: attrsFound) {
if
(attributes.hasAttribute(node.getIdentifier(),attribute)) {
@@ -266,7 +274,7 @@
if (edgeSet == null)
return true;
- // We we know all of the attributes we're interested in -- see
if these objects have any of them
+ // We know all of the attributes we're interested in -- see if
these objects have any of them
ArrayList<String>hasAttrs = new ArrayList();
for (CyEdge edge: edgeSet) {
for (String attribute: attrsFound) {
@@ -302,6 +310,10 @@
return positionList[labelPositionIndex].labelPosition();
}
+ public String getLabelAttribute() {
+ return labelAttribute;
+ }
+
private List<String> getMatchingAttributes(CyAttributes attributes,
List<String> compoundAttributes) {
// Get the names of all of the object attributes
String[] attrNames = attributes.getAttributeNames();
@@ -317,18 +329,25 @@
}
private void updateAttributeTunables() {
- List<String>possibleAttributes =
getAllAttributes(Cytoscape.getNodeAttributes(),
-
Cytoscape.getEdgeAttributes());
+ possibleAttributes =
getAllAttributes(Cytoscape.getNodeAttributes(),
+
Cytoscape.getEdgeAttributes(), true);
// Get the smiles tunable
Tunable t = properties.get("smilesAttributes");
t.setLowerBound((Object[])possibleAttributes.toArray());
String smilesDefaults = getDefaults(possibleAttributes,
defaultSmilesAttributes);
t.setValue(smilesDefaults);
// Repeat for the inCHI tunable
- t = properties.get("inChiAttributes");
- t.setLowerBound((Object[])possibleAttributes.toArray());
+ Tunable t2 = properties.get("inChiAttributes");
+ t2.setLowerBound((Object[])possibleAttributes.toArray());
String inCHIDefaults = getDefaults(possibleAttributes,
defaultInCHIAttributes);
- t.setValue(inCHIDefaults);
+ t2.setValue(inCHIDefaults);
+
+ // And the label attribute tunable
+ possibleAttributes =
getAllAttributes(Cytoscape.getNodeAttributes(),
+
Cytoscape.getEdgeAttributes(), false);
+ Tunable t3 = properties.get("labelAttribute");
+ t3.setLowerBound((Object[])possibleAttributes.toArray());
+ t3.setValue(new Integer(0));
}
private void initializeProperties() {
@@ -350,8 +369,8 @@
properties.add(t);
*/
- List<String>possibleAttributes =
getAllAttributes(Cytoscape.getNodeAttributes(),
-
Cytoscape.getEdgeAttributes());
+ possibleAttributes =
getAllAttributes(Cytoscape.getNodeAttributes(),
+
Cytoscape.getEdgeAttributes(), true);
properties.add(new Tunable("attributeGroup",
"Attribute Settings",
@@ -377,7 +396,7 @@
Tunable.LIST, inCHIDefaults,
(Object)possibleAttributes.toArray(),
inCHIDefaults, Tunable.MULTISELECT));
- properties.add(new Tunable("presentationGroup2", "Depiction
options", Tunable.GROUP, new Integer(2)));
+ properties.add(new Tunable("presentationGroup2", "Depiction
options", Tunable.GROUP, new Integer(3)));
properties.add(new Tunable("nodeStructureSize",
"Size of 2D node depiction as a % of node size",
@@ -388,23 +407,33 @@
Tunable.LIST, new Integer(labelPositionIndex),
(Object)positionList, null, 0));
+ possibleAttributes =
getAllAttributes(Cytoscape.getNodeAttributes(),
+
Cytoscape.getEdgeAttributes(), false);
+ properties.add( new Tunable("labelAttribute",
+ "Attribute to use for image label",
+ Tunable.LIST, new Integer(0),
(Object)possibleAttributes.toArray(),
+ null, 0));
+
properties.initializeProperties();
}
- private List<String> getAllAttributes(CyAttributes nodeAttributes,
CyAttributes edgeAttributes) {
+ private List<String> getAllAttributes(CyAttributes nodeAttributes,
CyAttributes edgeAttributes, boolean restrict) {
List<String>attributes = new ArrayList();
- getAttributes(attributes,nodeAttributes,"node.");
- getAttributes(attributes,edgeAttributes,"edge.");
+ attributes.add("none");
+ getAttributes(attributes,nodeAttributes,"node.", restrict);
+ getAttributes(attributes,edgeAttributes,"edge.", restrict);
return attributes;
}
- private void getAttributes(List<String>attributes, CyAttributes attrs,
String prefix) {
+ private void getAttributes(List<String>attributes, CyAttributes attrs,
String prefix, boolean restrict) {
String[] names = attrs.getAttributeNames();
for (int i = 0; i < names.length; i++) {
byte type = attrs.getType(names[i]);
- if ((type == CyAttributes.TYPE_STRING || type ==
CyAttributes.TYPE_SIMPLE_LIST)
- && attrs.getUserVisible(names[i])) {
+ if (!restrict && attrs.getUserVisible(names[i])) {
attributes.add(prefix+names[i]);
+ } else if ((type == CyAttributes.TYPE_STRING || type ==
CyAttributes.TYPE_SIMPLE_LIST)
+ &&
attrs.getUserVisible(names[i])) {
+ attributes.add(prefix+names[i]);
}
}
}
Modified: csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
2010-02-12 20:53:55 UTC (rev 19322)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/CompoundPopup.java
2010-02-12 21:27:04 UTC (rev 19323)
@@ -71,12 +71,15 @@
private List<Compound> compoundList;
private Map<Component, Compound> imageMap;
+ private String labelAttribute;
+ private static final int LABEL_HEIGHT = 20;
- public CompoundPopup(List<Compound> compoundList, List<GraphObject>
objectList) {
+ 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 (go instanceof CyNode) {
if (objectList.size() == 1) {
setTitle("2D Structures for Node
"+((CyNode)go).getIdentifier());
@@ -102,31 +105,51 @@
public void componentMoved(ComponentEvent e) {}
public void componentShown(ComponentEvent e) {}
public void componentResized(ComponentEvent e) {
- Component labelComponent = e.getComponent();
+ JLabel labelComponent = (JLabel)e.getComponent();
// Get our new width
int width = labelComponent.getWidth();
int height = labelComponent.getHeight();
+ String label = labelComponent.getText();
+ if (label != null && label.length() > 0)
+ height = height - LABEL_HEIGHT;
// Is it in our map?
if (imageMap.containsKey(labelComponent)) {
- JLabel label = (JLabel)(labelComponent);
Image img =
imageMap.get(labelComponent).getImage(width,height);
- label.setIcon(new ImageIcon(img));
+ labelComponent.setIcon(new ImageIcon(img));
}
}
// TODO: Add labels on image squares
private void addImages(int width) {
+ CyAttributes attributes = null;
+
// How many images do we have?
int structureCount = compoundList.size();
int nCols = (int)Math.sqrt((double)structureCount);
GridLayout layout = new GridLayout(nCols, structureCount/nCols,
1, 1);
setLayout(layout);
+ // Get the right attributes
+ if (labelAttribute.startsWith("node."))
+ attributes = Cytoscape.getNodeAttributes();
+ else if (labelAttribute.startsWith("edge."))
+ attributes = Cytoscape.getEdgeAttributes();
+ else
+ labelAttribute = null;
+
for (Compound compound: compoundList) {
// Get the image
- Image img = compound.getImage(width/nCols, width/nCols,
Color.WHITE);
- JLabel label = new JLabel(new ImageIcon(img));
+ Image img = compound.getImage(width/nCols,
width/nCols-LABEL_HEIGHT, Color.WHITE);
+ JLabel label;
+ if (labelAttribute == null) {
+ label = new JLabel(new ImageIcon(img));
+ } else {
+ String textLabel =
attributes.getAttribute(compound.getSource().getIdentifier(),labelAttribute.substring(5)).toString();
+ label = new JLabel(textLabel, new
ImageIcon(img), JLabel.CENTER);
+ label.setVerticalTextPosition(JLabel.BOTTOM);
+ label.setHorizontalTextPosition(JLabel.CENTER);
+ }
label.addComponentListener(this);
imageMap.put(label, compound);
add (label);
Modified:
csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/TableMouseAdapter.java
===================================================================
--- csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/TableMouseAdapter.java
2010-02-12 20:53:55 UTC (rev 19322)
+++ csplugins/trunk/ucsf/scooter/chemViz/src/chemViz/ui/TableMouseAdapter.java
2010-02-12 21:27:04 UTC (rev 19323)
@@ -113,7 +113,7 @@
public void run() {
List<GraphObject>goList = new
ArrayList();
goList.add(c.getSource());
- CompoundPopup popup = new
CompoundPopup(cList, goList);
+ CompoundPopup popup = new
CompoundPopup(cList, goList, null);
popup.toFront();
}
};
--
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.