Author: kono
Date: 2009-07-30 15:40:00 -0700 (Thu, 30 Jul 2009)
New Revision: 17630

Removed:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/visualproperty/BackgroundImage.java
Modified:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NodeRenderer.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Cube.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/visualproperty/ProcessingVisualLexicon.java
Log:
Experimental version of graph renderer runs at this point.

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NodeRenderer.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NodeRenderer.java
      2009-07-30 18:35:16 UTC (rev 17629)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NodeRenderer.java
      2009-07-30 22:40:00 UTC (rev 17630)
@@ -1,49 +1,38 @@
 package org.cytoscape.view.presentation.processing.internal;
 
-import static 
org.cytoscape.view.presentation.processing.visualproperty.ProcessingVisualLexicon.NODE_STYLE;
-import static org.cytoscape.view.presentation.property.ThreeDVisualLexicon.*;
+import static 
org.cytoscape.view.presentation.processing.visualproperty.ProcessingVisualLexicon.*;
 
-
 import org.cytoscape.model.CyNode;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualLexicon;
-import org.cytoscape.view.presentation.VisualItemRenderer;
 import org.cytoscape.view.presentation.processing.CyDrawable;
 import org.cytoscape.view.presentation.processing.internal.shape.Cube;
 import org.cytoscape.view.presentation.property.BasicVisualLexicon;
 
 import processing.core.PApplet;
 
-public class P5NodeRenderer implements VisualItemRenderer<View<CyNode>> {
+public class P5NodeRenderer extends AbstractRenderer<View<CyNode>> {
 
-       private PApplet p;
-       
-       private final VisualLexicon nodeLexicon;
-       
        public P5NodeRenderer(PApplet p) {
-               this.p = p;
-               nodeLexicon = buildLexicon();
+               super(p);
        }
-       
-       private VisualLexicon buildLexicon() {
-               final VisualLexicon sub = new BasicVisualLexicon();
-               System.out.println("%%%%%%%%%%%%% Building VP1");
-               sub.addVisualProperty(NODE_COLOR);
-               
-               sub.addVisualProperty(NODE_X_LOCATION);
-               sub.addVisualProperty(NODE_Y_LOCATION);
-               sub.addVisualProperty(NODE_Z_LOCATION);
-               System.out.println("%%%%%%%%%%%%% Building VP2");
-               //sub.addVisualProperty(ProcessingVisualLexicon.NODE_STYLE);
-               
-               sub.addVisualProperty(NODE_X_SIZE);
-               sub.addVisualProperty(NODE_Y_SIZE);
-               System.out.println("%%%%%%%%%%%%% Building VP3");
-               
-               return sub;
-       }
 
-       public VisualLexicon getVisualLexicon() {
+       /**
+        * Build a list of Visual Properties compatible with this renderer.
+        */
+       protected VisualLexicon buildLexicon() {
+               final VisualLexicon nodeLexicon = new BasicVisualLexicon();
+               nodeLexicon.addVisualProperty(NODE_COLOR);
+               nodeLexicon.addVisualProperty(NODE_LABEL_COLOR);
+
+               nodeLexicon.addVisualProperty(NODE_X_LOCATION);
+               nodeLexicon.addVisualProperty(NODE_Y_LOCATION);
+               nodeLexicon.addVisualProperty(NODE_Z_LOCATION);
+
+               nodeLexicon.addVisualProperty(NODE_X_SIZE);
+               nodeLexicon.addVisualProperty(NODE_Y_SIZE);
+               nodeLexicon.addVisualProperty(NODE_Z_SIZE);
+               
                return nodeLexicon;
        }
 
@@ -51,14 +40,14 @@
                // If Style property is available, use it.
                CyDrawable style = view.getVisualProperty(NODE_STYLE);
                
+
                // If not available, use the default CyDrawable, which is a 
cube.
-               if(style == null) 
-                       style = new Cube(p, nodeLexicon);
-               
+               if (style == null)
+                       style = new Cube(p, lexicon);
+
                style.setContext(view);
-               
+
                return style;
        }
 
-
 }

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   2009-07-30 18:35:16 UTC (rev 17629)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   2009-07-30 22:40:00 UTC (rev 17630)
@@ -1,10 +1,9 @@
 package org.cytoscape.view.presentation.processing.internal;
 
-import gestalt.render.Drawable;
-
-import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.Image;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
 import java.awt.print.Printable;
 import java.util.List;
 import java.util.Properties;
@@ -24,18 +23,17 @@
 import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.presentation.RenderingEngine;
 import org.cytoscape.view.presentation.processing.CyDrawable;
+import org.cytoscape.view.presentation.processing.Pickable;
 import 
org.cytoscape.view.presentation.processing.internal.particle.ParticleManager;
-import org.cytoscape.view.presentation.processing.internal.shape.Cube;
 
-import com.sun.opengl.util.FPSAnimator;
-
 import processing.core.PApplet;
 import processing.core.PFont;
 import processing.opengl.PGraphicsOpenGL;
 import toxi.geom.AABB;
-import toxi.geom.Vec3D;
 import toxi.physics.VerletPhysics;
 
+import com.sun.opengl.util.FPSAnimator;
+
 public class ProcessingNetworkRenderer extends PApplet implements
                RenderingEngine {
 
@@ -75,6 +73,15 @@
                this.nodeRenderer = new P5NodeRenderer(this);
                this.edgeRenderer = new P5EdgeRenderer(this, view);
 
+               
+               this.addMouseWheelListener(new MouseWheelListener() {
+
+                       public void mouseWheelMoved(MouseWheelEvent e) {
+                               zoom +=e.getWheelRotation()*100;
+                               
+                       }
+                       
+               });
                System.out.println("\n\n\n\n\n\n!!!!!!!!!! Calling constructor: 
");
        }
 
@@ -165,14 +172,6 @@
                edges = new CyDrawable[edgeViews.size()];
                for (int i = 0; i < edges.length; i++)
                        edges[i] = edgeRenderer.render(edgeViews.get(i));
-
-               canvas = new GLCanvas(); 
-                 canvas.setSize(200, 200); 
-                 canvas.addGLEventListener(new GLRenderer()); 
-                 FPSAnimator animator = new FPSAnimator(canvas, 60); 
-                 animator.start(); 
-                
-                 add(canvas); 
                
                
                System.out.println("%%%%%%%%%%%%% Setup DONE for P5");
@@ -182,14 +181,18 @@
                background(240);
                lights();
                
-               camera(width / 2.0f, height / 2.0f, (height / 2.0f)
-                               / tan((float) (PI * 60.0 / 360.0)) + zoom, 
width / 2.0f,
-                               height / 2.0f, 0, 0, 1, 0);
+//             camera(width / 2.0f, height / 2.0f, (height / 2.0f)
+//                             / tan((float) (PI * 60.0 / 360.0)) + zoom, 
width / 2.0f,
+//                             height / 2.0f, 0, 0, 1, 0);
                
+               camera(width / 2.0f, height / 2.0f, (height / 2.0f) / 
tan((float) (PI * 60.0 / 360.0)) + zoom, 
+                               width / 2.0f, height / 2.0f, 0, 
+                               0, 1, 0);
+               
                translate(width / 2, height / 2, height / 2);
                rotateX(rotY);
                rotateY(rotX);
-               translate(-width / 2 + transX, -height / 2 + transY, -height / 
2);
+               translate(-width / 2 + translateX, -height / 2 + translateY, 
-height / 2);
                beginGL();
                for (CyDrawable node : nodes)
                        node.draw();
@@ -213,14 +216,32 @@
                pgl.endGL();
        }
 
+       float translateX = 0;
+       float translateY = 0;
        public void mouseDragged() {
                if (mouseButton == RIGHT) {
-                       zoom += (mouseY - pmouseY) * 2;
-               } else if (mouseButton == LEFT) {
                        rotX += (mouseX - pmouseX) * 0.01;
                        rotY -= (mouseY - pmouseY) * 0.01;
+               } else if (mouseButton == LEFT) {
+                       translateX += (mouseX - pmouseX) * 2;
+                       translateY += (mouseY - pmouseY) * 2;
                }
+//             else if (mouseButton == LEFT) {
+//                     
+//             }
        }
+       
+       public void mousePressed() {
+               if(mouseButton != CENTER) return;
+               
+               System.out.println("===Mouse Click");
+               for(int i=0; i<nodes.length; i++) {
+                       if(nodes[i] instanceof Pickable) {
+                               ((Pickable) nodes[i]).pick(mouseX, mouseY);
+                       }
+               }
+       }
+       
 
        public Icon getDefaultIcon(VisualProperty<?> vp) {
                // TODO Auto-generated method stub

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Cube.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Cube.java
  2009-07-30 18:35:16 UTC (rev 17629)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Cube.java
  2009-07-30 22:40:00 UTC (rev 17630)
@@ -18,8 +18,10 @@
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualLexicon;
 import org.cytoscape.view.presentation.processing.CyDrawable;
+import org.cytoscape.view.presentation.processing.Pickable;
 
 import processing.core.PApplet;
+import processing.core.PGraphics;
 import toxi.geom.Vec3D;
 
 /**
@@ -28,13 +30,17 @@
  * @author kono
  *
  */
-public class Cube extends Vec3D implements CyDrawable {
+public class Cube extends Vec3D implements CyDrawable, Pickable {
 
        private static final long serialVersionUID = -3971892445041605908L;
        private static final String DISPLAY_NAME = "Cube";
        
        private static final int DEF_SIZE = 20;
        
+       private static final int OFFSET = 10;
+
+       
+       private boolean picked;
        private Set<Class<?>> compatibleDataType;
        
        private final VisualLexicon lexicon;
@@ -49,6 +55,7 @@
                super();
                this.p = parent;
                this.lexicon = lexicon;
+               this.picked = false;
                
                compatibleDataType = new HashSet<Class<?>>();
                compatibleDataType.add(CyNode.class);
@@ -69,9 +76,9 @@
 
        public void draw() {
                p.pushMatrix();
+               p.noStroke();
                p.translate(x, y, z);
                p.fill(r, g, b, alpha);
-               //p.fill(204, 102, 0);
                p.box(size);
                p.popMatrix();
        }
@@ -92,16 +99,43 @@
                        size = DEF_SIZE;
                
                Paint color = viewModel.getVisualProperty(NODE_COLOR);
-               if(color instanceof Color) {
+               if(picked) {
+                       this.r = 0;
+                       g = 250;
+                       b = 0;
+                       alpha = 255;
+                       System.out.println("Color of PICKED node" + g); 
+               }else if(color instanceof Color) {
                        this.r = ((Color)color).getRed();
                        this.g = ((Color)color).getGreen();
                        this.b = ((Color)color).getBlue();
                        //this.alpha = ((Color)color).getAlpha();
                        this.alpha = 90;
-                       System.out.println("Color of node = " + r +", " + g + 
", " + b + ", alpha = " + alpha);
+                       
                }
                
                
        }
 
+       public boolean isPicked() {
+               return picked;
+       }
+
+       public void pick(float cx, float cy) {
+               
+               final float distance = PApplet.dist(cx, cy, p.screenX(this.x, 
this.y, this.z), p.screenY(x, y, z));
+               System.out.println("Distance = " + distance);
+               if(distance < 200){
+                       picked = true;
+                       System.out.println("PICKED!!");
+                       this.r = 0;
+                       g = 250;
+                       b = 0;
+                       alpha = 255;
+                       System.out.println("Color of PICKED node" + g); 
+               } else
+                       picked = false;
+               
+       }
+
 }

Deleted: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/visualproperty/BackgroundImage.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/visualproperty/BackgroundImage.java
       2009-07-30 18:35:16 UTC (rev 17629)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/visualproperty/BackgroundImage.java
       2009-07-30 22:40:00 UTC (rev 17630)
@@ -1,5 +0,0 @@
-package org.cytoscape.view.presentation.processing.visualproperty;
-
-public interface BackgroundImage {
-
-}

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/visualproperty/ProcessingVisualLexicon.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/visualproperty/ProcessingVisualLexicon.java
       2009-07-30 18:35:16 UTC (rev 17629)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/visualproperty/ProcessingVisualLexicon.java
       2009-07-30 22:40:00 UTC (rev 17630)
@@ -1,8 +1,9 @@
 package org.cytoscape.view.presentation.processing.visualproperty;
 
-import static org.cytoscape.model.GraphObject.EDGE;
+import static org.cytoscape.model.GraphObject.*;
 import static org.cytoscape.model.GraphObject.NODE;
 
+import java.awt.Image;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -20,6 +21,9 @@
        public static final VisualProperty<? extends CyDrawable> EDGE_STYLE = 
new CyDrawableVisualProperty(
                        EDGE, null, "EDGE_STYLE", "Edge Style");        
        
+       public static final VisualProperty<? extends Image> 
NETWORK_BACKGROUND_IMAGE = new ImageVisualProperty(
+                       NETWORK, null, "NETWORK_BACKGROUND_IMAGE", "Network 
Background Image"); 
+       
        public ProcessingVisualLexicon() {
                super();
                this.visualPropertySet.add(NODE_STYLE);


--~--~---------~--~----~------------~-------~--~----~
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