Author: ruschein
Date: 2009-12-01 16:20:48 -0800 (Tue, 01 Dec 2009)
New Revision: 18638

Modified:
   corelibs/trunk/ding/src/ding/view/DGraphView.java
Log:
Made nested network images' transparent.

Modified: corelibs/trunk/ding/src/ding/view/DGraphView.java
===================================================================
--- corelibs/trunk/ding/src/ding/view/DGraphView.java   2009-12-02 00:04:26 UTC 
(rev 18637)
+++ corelibs/trunk/ding/src/ding/view/DGraphView.java   2009-12-02 00:20:48 UTC 
(rev 18638)
@@ -2350,13 +2350,14 @@
         *
         * @param width Width of desired image.
         * @param height Height of desired image.
-        * @param shrink Percent to shrink the network shown in the image. 
+        * @param shrink Percent to shrink the network shown in the image.
+        * @param skipBackground If true, we don't draw the background
         * This doesn't shrink the image, just the network shown, as if the 
user zoomed out.
         * Can be between 0 and 1, if not it will default to 1.  
         * @return Image
         * @throws IllegalArgumentException
         */
-       public Image createImage(int width, int height, double shrink) {
+       private Image createImage(final int width, final int height, double 
shrink, final boolean skipBackground) {
                // Validate arguments
                if (width < 0 || height < 0) {
                        throw new 
IllegalArgumentException("DGraphView.createImage(int width, int height): "
@@ -2373,13 +2374,17 @@
                final Image image = new BufferedImage(width, height, 
BufferedImage.TYPE_INT_ARGB_PRE);          
                final Graphics g = image.getGraphics();
 
-               // paint background canvas into image
-               Dimension originalSize = m_backgroundCanvas.getSize();
-               m_backgroundCanvas.setSize(width, height);
-               m_backgroundCanvas.paint(g);
-               // Restore background size
-               m_backgroundCanvas.setSize(originalSize);
+               Dimension originalSize;
 
+               if (!skipBackground) {
+                       // paint background canvas into image
+                       originalSize = m_backgroundCanvas.getSize();
+                       m_backgroundCanvas.setSize(width, height);
+                       m_backgroundCanvas.paint(g);
+                       // Restore background size
+                       m_backgroundCanvas.setSize(originalSize);
+               }
+               
                // paint inner canvas (network)
                originalSize = m_networkCanvas.getSize();
                m_networkCanvas.setSize(width, height);
@@ -2402,6 +2407,23 @@
 
 
        /**
+        * Method to return a reference to an Image object,
+        * which represents the current network view.
+        *
+        * @param width Width of desired image.
+        * @param height Height of desired image.
+        * @param shrink Percent to shrink the network shown in the image. 
+        * This doesn't shrink the image, just the network shown, as if the 
user zoomed out.
+        * Can be between 0 and 1, if not it will default to 1.  
+        * @return Image
+        * @throws IllegalArgumentException
+        */
+       public Image createImage(int width, int height, double shrink) {
+               return createImage(width, height, shrink, /* skipBackground = 
*/ false);
+       }
+
+
+       /**
         * utility that returns the nodeView that is located at input point
         *
         * @param pt
@@ -2585,7 +2607,7 @@
                if (!latest) {
                        // Need to update snapshot.
                        final Rectangle2D rect = new 
Rectangle2D.Double(-width/2, -height/2, width, height);
-                       snapshotImage = new TexturePaint((BufferedImage) 
createImage(DEF_SNAPSHOT_SIZE, DEF_SNAPSHOT_SIZE, 1), rect);
+                       snapshotImage = new TexturePaint((BufferedImage) 
createImage(DEF_SNAPSHOT_SIZE, DEF_SNAPSHOT_SIZE, 1, /* skipBackground = */ 
true), rect);
                        latest = 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.


Reply via email to