Author: ruschein
Date: 2009-12-30 17:17:45 -0800 (Wed, 30 Dec 2009)
New Revision: 18811
Modified:
cytoscape/trunk/lib/ding.jar
cytoscape/trunk/lib/giny.jar
cytoscape/trunk/src/cytoscape/CyNode.java
cytoscape/trunk/src/cytoscape/visual/ui/NestedNetworkMenuListener.java
Log:
Added support for hiding/showing nested networks via a new
"nested_network_is_visible" attribute.
Modified: cytoscape/trunk/lib/ding.jar
===================================================================
(Binary files differ)
Modified: cytoscape/trunk/lib/giny.jar
===================================================================
(Binary files differ)
Modified: cytoscape/trunk/src/cytoscape/CyNode.java
===================================================================
--- cytoscape/trunk/src/cytoscape/CyNode.java 2009-12-31 01:16:17 UTC (rev
18810)
+++ cytoscape/trunk/src/cytoscape/CyNode.java 2009-12-31 01:17:45 UTC (rev
18811)
@@ -52,15 +52,16 @@
*/
public class CyNode implements giny.model.Node {
public static final String NESTED_NETWORK_ID_ATTR = "nested_network_id";
+ public static final String NESTED_NETWORK_IS_VISIBLE_ATTR =
"nested_network_is_visible";
public static final String HAS_NESTED_NETWORK_ATTR =
"has_nested_network";
public static final String PARENT_NODES_ATTR = "parent_nodes";
-
+
// Variables specific to public get/set methods.
CytoscapeFingRootGraph m_rootGraph = null;
int m_rootGraphIndex = 0;
String m_identifier = null;
ArrayList<CyGroup> groupList = null;
-
+
private GraphPerspective nestedNetwork;
/**
@@ -247,14 +248,13 @@
return;
final GraphPerspective oldNestedNetwork = this.nestedNetwork;
-
+ final String nodeID = this.getIdentifier();
+
// create a Node Attribute "nested.network.id" for this Node
final String networkID = ((CyNetwork)(graphPerspective == null
? this.nestedNetwork : graphPerspective)).getIdentifier();
this.nestedNetwork = graphPerspective;
-
-
Cytoscape.getNodeAttributes().setAttribute(this.getIdentifier(),
NESTED_NETWORK_ID_ATTR, networkID);
-
- // create or update Network Attribute "parent.node.name.list"
for the Network
+
+ // create or update Network Attribute "parent.node.name.list"
for the Network
final String[] attributeNames =
Cytoscape.getNetworkAttributes().getAttributeNames();
boolean attrFound = false;
for (final String name : attributeNames) {
@@ -266,35 +266,39 @@
List<String> parentNodeList;
if (!attrFound) {
parentNodeList = new ArrayList<String>();
- parentNodeList.add(this.getIdentifier());
+ parentNodeList.add(nodeID);
} else {
parentNodeList = (List<String>)
Cytoscape.getNetworkAttributes().getListAttribute(networkID, PARENT_NODES_ATTR);
if (this.nestedNetwork != null) {
- parentNodeList.add(this.getIdentifier());
+ parentNodeList.add(nodeID);
} else {
- parentNodeList.remove(this.getIdentifier());
+ parentNodeList.remove(nodeID);
}
}
Cytoscape.getNetworkAttributes().setListAttribute(networkID,
PARENT_NODES_ATTR, parentNodeList);
// tag or untag the node as having a nested network
if (graphPerspective != null) {
-
Cytoscape.getNodeAttributes().setAttribute(this.getIdentifier(),
HAS_NESTED_NETWORK_ATTR, "yes");
+ Cytoscape.getNodeAttributes().setAttribute(nodeID,
HAS_NESTED_NETWORK_ATTR, "yes");
+ Cytoscape.getNodeAttributes().setAttribute(nodeID,
NESTED_NETWORK_IS_VISIBLE_ATTR, new Boolean(true));
+ Cytoscape.getNodeAttributes().setAttribute(nodeID,
NESTED_NETWORK_ID_ATTR, networkID);
} else {
-
Cytoscape.getNodeAttributes().deleteAttribute(this.getIdentifier(),
HAS_NESTED_NETWORK_ATTR);
+ Cytoscape.getNodeAttributes().deleteAttribute(nodeID,
HAS_NESTED_NETWORK_ATTR);
+ Cytoscape.getNodeAttributes().deleteAttribute(nodeID,
NESTED_NETWORK_IS_VISIBLE_ATTR);
+ Cytoscape.getNodeAttributes().deleteAttribute(nodeID,
NESTED_NETWORK_ID_ATTR);
}
-
+
// Let listeners know that the previous nested network was
removed
if (oldNestedNetwork != null)
Cytoscape.getPropertyChangeSupport().firePropertyChange(Cytoscape.NESTED_NETWORK_DESTROYED,
this, oldNestedNetwork);
-
+
// Let listeners know nested network was assigned to this node.
if (this.nestedNetwork != null) {
Cytoscape.getPropertyChangeSupport().firePropertyChange(Cytoscape.NESTED_NETWORK_CREATED,
this, graphPerspective);
}
}
-
-
+
+
/**
* Return the currently set graph perspective (may be null) associated
with this node.
*
@@ -303,4 +307,23 @@
public GraphPerspective getNestedNetwork() {
return nestedNetwork;
}
+
+ /** Determines whether a nested network should be rendered as part of a
node's view or not.
+ * @return true if the node has a nested network and we want it
rendered, else false.
+ */
+ public boolean nestedNetworkIsVisible() {
+ final Boolean nestedNetworkIsVisibleAttr =
Cytoscape.getNodeAttributes().getBooleanAttribute(this.getIdentifier(),
NESTED_NETWORK_IS_VISIBLE_ATTR);
+ return nestedNetworkIsVisibleAttr != null &&
nestedNetworkIsVisibleAttr;
+ }
+
+ /** Set the visibility of a node's nested network when rendered.
+ * @param makeVisible forces the visibility of a nested network.
+ * Please note that this call has no effect if a node has no associated
nested network!
+ */
+ public void showNestedNetwork(final boolean makeVisible) {
+ if (getNestedNetwork() == null || nestedNetworkIsVisible() ==
makeVisible)
+ return;
+
+
Cytoscape.getNodeAttributes().setAttribute(this.getIdentifier(),
NESTED_NETWORK_IS_VISIBLE_ATTR, new Boolean(makeVisible));
+ }
}
Modified: cytoscape/trunk/src/cytoscape/visual/ui/NestedNetworkMenuListener.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/ui/NestedNetworkMenuListener.java
2009-12-31 01:16:17 UTC (rev 18810)
+++ cytoscape/trunk/src/cytoscape/visual/ui/NestedNetworkMenuListener.java
2009-12-31 01:17:45 UTC (rev 18811)
@@ -50,6 +50,7 @@
import cytoscape.dialogs.SetNestedNetworkDialog;
import javax.swing.JOptionPane;
+
/**
* NestedNetworkMenuListener implements NodeContextMenuListener
* When a node is selected it calls NestedNetwork and add
@@ -61,17 +62,20 @@
* @param nodeView The clicked NodeView
* @param menu popup menu to add the Bypass menu
*/
- public void addNodeContextMenuItems(NodeView nodeView, JPopupMenu menu)
{
- if (menu == null){
- menu = new JPopupMenu();
- }
- JMenu jm = new JMenu("Nested network");
-
+ public void addNodeContextMenuItems(final NodeView nodeView, JPopupMenu
menu) {
+ if (menu == null)
+ menu = new JPopupMenu();
+
+ JMenu jm = new JMenu("Nested Network");
+
final JMenuItem jm1 = new JCheckBoxMenuItem(new
SetNestedNetworkMenuItemAction(nodeView));
final JMenuItem jm2 = new JCheckBoxMenuItem(new
DeleteNestedNetworkMenuItemAction(nodeView));
final JMenuItem jm3 = new JCheckBoxMenuItem(new
GotoNestedNetworkMenuItemAction(nodeView));
+ final JMenuItem jm4 =
nodeView.getNode().nestedNetworkIsVisible()
+ ? new JCheckBoxMenuItem(new
HideNestedNetworkMenuItemAction(nodeView))
+ : new JCheckBoxMenuItem(new
ShowNestedNetworkMenuItemAction(nodeView));
- if (nodeView.getNode().getNestedNetwork() == null){
+ if (nodeView.getNode().getNestedNetwork() == null) {
jm2.setEnabled(false);
jm3.setEnabled(false);
}
@@ -79,69 +83,97 @@
jm.add(jm1);
jm.add(jm2);
jm.add(jm3);
-
+ jm.add(jm4);
+
menu.add(jm);
}
-
- //
+
class SetNestedNetworkMenuItemAction extends AbstractAction {
NodeView nodeView;
- public SetNestedNetworkMenuItemAction(NodeView nodeView){
+ public SetNestedNetworkMenuItemAction(NodeView nodeView) {
super("Set Nested Network");
this.nodeView = nodeView;
}
-
+
public void actionPerformed(ActionEvent e) {
SetNestedNetworkDialog dlg = new
SetNestedNetworkDialog(Cytoscape.getDesktop(), true, this.nodeView);
- //"Set Nested Network for " +
nodeView.getNode().getIdentifier());
dlg.setLocationRelativeTo(Cytoscape.getDesktop());
dlg.setVisible(true);
}
}
- //
+
class DeleteNestedNetworkMenuItemAction extends AbstractAction {
NodeView nodeView;
- public DeleteNestedNetworkMenuItemAction(NodeView nodeView){
+ public DeleteNestedNetworkMenuItemAction(NodeView nodeView) {
super("Delete Nested Network");
this.nodeView = nodeView;
}
-
+
public void actionPerformed(ActionEvent e) {
- if (this.nodeView.getNode().getNestedNetwork() == null){
+ if (this.nodeView.getNode().getNestedNetwork() == null)
{
return;
}
- int user_says =
JOptionPane.showConfirmDialog(Cytoscape.getDesktop(),
+ int user_says =
JOptionPane.showConfirmDialog(Cytoscape.getDesktop(),
"Are you sure you want to delete this
nested network?","Confirm Delete Nested Network", JOptionPane.YES_NO_OPTION);
- if (user_says == JOptionPane.NO_OPTION){
+ if (user_says == JOptionPane.NO_OPTION) {
return;
}
-
- this.nodeView.getNode().setNestedNetwork(null);
+
+ this.nodeView.getNode().setNestedNetwork(null);
}
}
+
class GotoNestedNetworkMenuItemAction extends AbstractAction {
NodeView nodeView;
- public GotoNestedNetworkMenuItemAction(NodeView nodeView){
+ public GotoNestedNetworkMenuItemAction(NodeView nodeView) {
super("Go to Nested Network");
this.nodeView = nodeView;
}
-
+
public void actionPerformed(ActionEvent e) {
- if (this.nodeView.getNode().getNestedNetwork() == null){
+ if (this.nodeView.getNode().getNestedNetwork() == null)
{
return;
}
-
+
CyNetwork nestedNetwork = (CyNetwork)
this.nodeView.getNode().getNestedNetwork();
-
+
CyNetworkView theView =
Cytoscape.getNetworkView(nestedNetwork.getIdentifier());
- if (theView == null || theView.getIdentifier() == null){
+ if (theView == null || theView.getIdentifier() == null)
{
theView =
Cytoscape.createNetworkView(nestedNetwork);
}
Cytoscape.getDesktop().setFocus(nestedNetwork.getIdentifier());
}
}
+
+
+ class ShowNestedNetworkMenuItemAction extends AbstractAction {
+ NodeView nodeView;
+ public ShowNestedNetworkMenuItemAction(final NodeView nodeView)
{
+ super("Show Nested Network");
+ this.nodeView = nodeView;
+ }
+
+ public void actionPerformed(final ActionEvent e) {
+ this.nodeView.getNode().showNestedNetwork(true);
+ Cytoscape.getCurrentNetworkView().redrawGraph(false,
true);
+ }
+ }
+
+
+ class HideNestedNetworkMenuItemAction extends AbstractAction {
+ NodeView nodeView;
+ public HideNestedNetworkMenuItemAction(final NodeView nodeView)
{
+ super("Hide Nested Network");
+ this.nodeView = nodeView;
+ }
+
+ public void actionPerformed(final ActionEvent e) {
+ this.nodeView.getNode().showNestedNetwork(false);
+ Cytoscape.getCurrentNetworkView().redrawGraph(false,
true);
+ }
+ }
}
--
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.