Author: kono
Date: 2009-11-30 18:45:24 -0800 (Mon, 30 Nov 2009)
New Revision: 18617

Modified:
   corelibs/trunk/ding/src/ding/view/DGraphView.java
   corelibs/trunk/ding/src/ding/view/DNodeView.java
Log:
Low quality nested network image problem fixed.  By default, create 2000px 
image and then shrink it to current node size. 

Modified: corelibs/trunk/ding/src/ding/view/DGraphView.java
===================================================================
--- corelibs/trunk/ding/src/ding/view/DGraphView.java   2009-12-01 01:49:38 UTC 
(rev 18616)
+++ corelibs/trunk/ding/src/ding/view/DGraphView.java   2009-12-01 02:45:24 UTC 
(rev 18617)
@@ -105,7 +105,7 @@
  */
 public class DGraphView implements GraphView, Printable {
        // Size of snapshot image
-       private static final int DEF_SNAPSHOT_SIZE = 500;
+       private static final int DEF_SNAPSHOT_SIZE = 2000;
        
        static final float DEFAULT_ANCHOR_SIZE = 9.0f;
        static final Paint DEFAULT_ANCHOR_SELECTED_PAINT = Color.red;
@@ -2561,13 +2561,7 @@
                if (!latest) {
                        // Need to update snapshot.
                        final Rectangle2D rect = new 
Rectangle2D.Double(-width/2, -height/2, width, height);
-                       snapshotImage = new TexturePaint((BufferedImage) 
createImage(width, height, 1), rect);
-//                     try {
-//                             snapshotImage = new 
TexturePaint(ImageIO.read(new 
File("/Users/kono/Documents/workspace/cytoscape/images/default_network.png")), 
rect);
-//                     } catch (IOException e) {
-//                             // TODO Auto-generated catch block
-//                             e.printStackTrace();
-//                     }
+                       snapshotImage = new TexturePaint((BufferedImage) 
createImage(DEF_SNAPSHOT_SIZE, DEF_SNAPSHOT_SIZE, 1), rect);
                        latest = true;
                } 
                

Modified: corelibs/trunk/ding/src/ding/view/DNodeView.java
===================================================================
--- corelibs/trunk/ding/src/ding/view/DNodeView.java    2009-12-01 01:49:38 UTC 
(rev 18616)
+++ corelibs/trunk/ding/src/ding/view/DNodeView.java    2009-12-01 02:45:24 UTC 
(rev 18617)
@@ -70,6 +70,9 @@
  * @author $author$
  */
 public class DNodeView implements NodeView, Label {
+       // For Cytoscape 2.7: Nested Network Image size
+       private static final float NESTED_IMAGE_SCALE_FACTOR = 0.7f;
+       
        static final float DEFAULT_WIDTH = 20.0f;
        static final float DEFAULT_HEIGHT = 20.0f;
        static final byte DEFAULT_SHAPE = GraphGraphics.SHAPE_ELLIPSE;
@@ -1007,11 +1010,11 @@
      * @see #addCustomGraphic(CustomGraphic)
      * @see cytoscape.render.stateful.CustomGraphic
      */
-      public CustomGraphic addCustomGraphic(Shape shape, Paint paint, byte 
anchor) {
-         CustomGraphic cg = new CustomGraphic (shape, paint, anchor);
-         addCustomGraphic (cg);
-         return cg;
-      }
+       public CustomGraphic addCustomGraphic(Shape shape, Paint paint, byte 
anchor) {
+               CustomGraphic cg = new CustomGraphic (shape, paint, anchor);
+               addCustomGraphic (cg);
+               return cg;
+       }
 
     /**
      * Adds a given CustomGraphic, <EM>in draw order</EM>, to this
@@ -1402,10 +1405,11 @@
 
        public TexturePaint getNestedNetworkTexturePaint() {
                synchronized (m_view.m_lock) {
-                       if (this.getNode().getNestedNetwork() != null && 
nestedNetworkView != null)
-                               return 
nestedNetworkView.getSnapshot((int)this.getWidth(), (int)this.getHeight());
-                       else
+                       if (this.getNode().getNestedNetwork() != null && 
nestedNetworkView != null) {
+                               return 
nestedNetworkView.getSnapshot((int)(getWidth()*NESTED_IMAGE_SCALE_FACTOR), 
(int)(getHeight()*NESTED_IMAGE_SCALE_FACTOR));
+                       } else {
                                return null;
+                       }
                }
        }
        

--

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