Author: ruschein
Date: 2009-12-18 13:26:56 -0800 (Fri, 18 Dec 2009)
New Revision: 18789

Modified:
   corelibs/trunk/ding/src/ding/view/DNodeView.java
Log:
Fixed Mantis bugs 2122,2123 which were caused by nested networks with circular 
references.

Modified: corelibs/trunk/ding/src/ding/view/DNodeView.java
===================================================================
--- corelibs/trunk/ding/src/ding/view/DNodeView.java    2009-12-18 19:44:32 UTC 
(rev 18788)
+++ corelibs/trunk/ding/src/ding/view/DNodeView.java    2009-12-18 21:26:56 UTC 
(rev 18789)
@@ -78,6 +78,10 @@
        
        // This image will be used when view is not available for a nested 
network.
        private static BufferedImage DEFAULT_NESTED_NETWORK_IMAGE;
+
+       // Used to detect recursive rendering of nested networks.
+       private static int nestedNetworkPaintingDepth = 0;
+
        static {
                try {
                        DEFAULT_NESTED_NETWORK_IMAGE = 
ImageIO.read(DNodeView.class.getClassLoader().getResource("resources/images/default_network.png"));
@@ -1449,20 +1453,24 @@
 
        TexturePaint getNestedNetworkTexturePaint() {
                synchronized (m_view.m_lock) {
-                       if (this.getNode().getNestedNetwork() != null) {
+                       ++nestedNetworkPaintingDepth;
+                       try {
+                               if (nestedNetworkPaintingDepth > 1 || 
getNode().getNestedNetwork() == null)
+                                       return null;
+
                                final double IMAGE_WIDTH  = 
getWidth()*NESTED_IMAGE_SCALE_FACTOR;
                                final double IMAGE_HEIGHT = 
getHeight()*NESTED_IMAGE_SCALE_FACTOR;
-                               if (nestedNetworkView != null) {
+                               if (nestedNetworkView != null)
                                        return 
nestedNetworkView.getSnapshot(IMAGE_WIDTH, IMAGE_HEIGHT);
-                               } else {
-                                       if (DEFAULT_NESTED_NETWORK_IMAGE == 
null) {
+                               else {
+                                       if (DEFAULT_NESTED_NETWORK_IMAGE == 
null)
                                                return null;
-                                       }
+
                                        final Rectangle2D rect = new 
Rectangle2D.Double(-IMAGE_WIDTH/2, -IMAGE_HEIGHT/2, IMAGE_WIDTH, IMAGE_HEIGHT);
                                        return new 
TexturePaint(DEFAULT_NESTED_NETWORK_IMAGE, rect);
                                }
-                       } else {
-                               return null;
+                       } finally {
+                               --nestedNetworkPaintingDepth;
                        }
                }
        }

--

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.


Reply via email to