Author: kono
Date: 2009-11-25 12:15:06 -0800 (Wed, 25 Nov 2009)
New Revision: 18581

Modified:
   cytoscape/trunk/src/cytoscape/Cytoscape.java
   cytoscape/trunk/src/cytoscape/ding/DingNetworkView.java
   cytoscape/trunk/src/cytoscape/util/NestedNetworkImageManager.java
Log:
Fixed background transparency problem and NETWORK_VIEW_CREATED event timing 
issue. 

Modified: cytoscape/trunk/src/cytoscape/Cytoscape.java
===================================================================
--- cytoscape/trunk/src/cytoscape/Cytoscape.java        2009-11-25 20:13:17 UTC 
(rev 18580)
+++ cytoscape/trunk/src/cytoscape/Cytoscape.java        2009-11-25 20:15:06 UTC 
(rev 18581)
@@ -1724,13 +1724,11 @@
                        layout = CyLayouts.getDefaultLayout();
                }
 
-               
Cytoscape.firePropertyChange(cytoscape.view.CytoscapeDesktop.NETWORK_VIEW_CREATED,
 null,
-                                            view);
-
                layout.doLayout(view);
 
-               view.fitContent();
+               
Cytoscape.firePropertyChange(cytoscape.view.CytoscapeDesktop.NETWORK_VIEW_CREATED,
 null, view);
 
+               view.fitContent();
                view.redrawGraph(false, true);
 
                return view;

Modified: cytoscape/trunk/src/cytoscape/ding/DingNetworkView.java
===================================================================
--- cytoscape/trunk/src/cytoscape/ding/DingNetworkView.java     2009-11-25 
20:13:17 UTC (rev 18580)
+++ cytoscape/trunk/src/cytoscape/ding/DingNetworkView.java     2009-11-25 
20:15:06 UTC (rev 18581)
@@ -160,7 +160,7 @@
         * @param vizmap DOCUMENT ME!
         */
        public void redrawGraph(boolean layout, boolean vizmap) {
-               VisualMappingManager vmm = Cytoscape.getVisualMappingManager();
+               final VisualMappingManager vmm = 
Cytoscape.getVisualMappingManager();
                vmm.setNetworkView(this);
                vmm.applyAppearances();
                updateView();

Modified: cytoscape/trunk/src/cytoscape/util/NestedNetworkImageManager.java
===================================================================
--- cytoscape/trunk/src/cytoscape/util/NestedNetworkImageManager.java   
2009-11-25 20:13:17 UTC (rev 18580)
+++ cytoscape/trunk/src/cytoscape/util/NestedNetworkImageManager.java   
2009-11-25 20:15:06 UTC (rev 18581)
@@ -1,5 +1,6 @@
 package cytoscape.util;
 
+import java.awt.Color;
 import java.awt.Image;
 import java.awt.TexturePaint;
 import java.awt.geom.Rectangle2D;
@@ -24,6 +25,8 @@
 import cytoscape.view.CytoscapeDesktop;
 import ding.view.DGraphView;
 import ding.view.DNodeView;
+import ding.view.DingCanvas;
+import ding.view.DGraphView.Canvas;
 
 
 /** This class manages images that represent nested networks.  This 
"management" includes creation, updating and destruction of such images as well
@@ -31,9 +34,11 @@
  */
 public class NestedNetworkImageManager implements PropertyChangeListener {
        private final Image DEF_IMAGE;
+               
+       private static final int DEF_WIDTH = 100;
+       private static final int DEF_HEIGHT = 100;
        
-       private static final int DEF_WIDTH = 500;
-       private static final int DEF_HEIGHT = 500;
+       private static final int IMG_SIZE = 500;
        
        private static NestedNetworkImageManager theNestedNetworkImageManager = 
null;
        private static Map<CyNetwork, ImageAndReferenceCount> networkToImageMap;
@@ -165,11 +170,12 @@
                        networkToImageMap.put(nestedNetwork, new 
ImageAndReferenceCount(DEF_IMAGE));
                } else {
                        // Create image from this view.
-                       view.applyLayout(CyLayouts.getLayout("force-directed"));
+                       
//view.applyLayout(CyLayouts.getLayout("force-directed"));
                        final DGraphView dView = (DGraphView) view;
-                       dView.fitContent();
-                       dView.updateView();
-                       final Image image = dView.createImage(DEF_WIDTH, 
DEF_HEIGHT, 1.0);
+                       final DingCanvas bCanvas = 
dView.getCanvas(Canvas.BACKGROUND_CANVAS);
+                       bCanvas.setOpaque(false);
+                       final Image image = dView.createImage(IMG_SIZE, 
IMG_SIZE, 1.0);
+                       bCanvas.setOpaque(true);
                        networkToImageMap.put(nestedNetwork, new 
ImageAndReferenceCount(image));
                }
        }
@@ -182,9 +188,9 @@
         * @param parentNode     the node that contains the nested network 
"nestedNetwork" and displayed in the view "networkView"
         */
        private void addCustomGraphics(final CyNetwork nestedNetwork, final 
CyNetworkView networkView, final CyNode parentNode) {
-               Image networkImage = getImage(nestedNetwork);
+               final Image networkImage = getImage(nestedNetwork);
                final DNodeView nodeView = 
(DNodeView)networkView.getNodeView(parentNode);
-               final Rectangle2D rect = new Rectangle2D.Double(-DEF_WIDTH/2, 
-DEF_HEIGHT/2, DEF_WIDTH, DEF_HEIGHT);            
+               final Rectangle2D rect = new Rectangle2D.Double(-DEF_WIDTH/2, 
-DEF_HEIGHT/2, DEF_WIDTH, DEF_HEIGHT);
                nodeView.addCustomGraphic(rect, new 
TexturePaint((BufferedImage) networkImage, rect), NodeDetails.ANCHOR_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.


Reply via email to