Author: kono
Date: 2009-07-31 18:30:19 -0700 (Fri, 31 Jul 2009)
New Revision: 17652

Added:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/CyQuad.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Rectangle.java
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/particle/ParticleManager.java
Log:
Front-end updated.

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-08-01 01:16:07 UTC (rev 17651)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   2009-08-01 01:30:19 UTC (rev 17652)
@@ -30,6 +30,8 @@
 import processing.core.PFont;
 import processing.opengl.PGraphicsOpenGL;
 import toxi.geom.AABB;
+import toxi.geom.Vec3D;
+import toxi.physics.VerletParticle;
 import toxi.physics.VerletPhysics;
 
 import com.sun.opengl.util.FPSAnimator;
@@ -43,6 +45,8 @@
        // Mode of renderer. For now, it is set to non-OpenGL version.
        private static final String MODE = P3D;
        private static final int FRAME_RATE = 30;
+       
+       private float fontSize = 32;
 
        private Dimension windowSize;
        private CyNetworkView view;
@@ -54,9 +58,14 @@
 
        private final P5NodeRenderer nodeRenderer;
        private final P5EdgeRenderer edgeRenderer;
-       
+
        private GLCanvas canvas;
 
+       private ParticleManager particleManager;
+       private VerletPhysics physics;
+       private float rotX, rotY, zoom = 200;
+       private AABB boundingBox;
+
        /**
         * Constructor. Create a PApplet component based on the size given as
         * parameter.
@@ -73,14 +82,13 @@
                this.nodeRenderer = new P5NodeRenderer(this);
                this.edgeRenderer = new P5EdgeRenderer(this, view);
 
-               
                this.addMouseWheelListener(new MouseWheelListener() {
 
                        public void mouseWheelMoved(MouseWheelEvent e) {
-                               zoom +=e.getWheelRotation()*100;
-                               
+                               zoom += e.getWheelRotation() * 100;
+
                        }
-                       
+
                });
                System.out.println("\n\n\n\n\n\n!!!!!!!!!! Calling constructor: 
");
        }
@@ -118,37 +126,32 @@
        PGraphicsOpenGL pgl;
        GL gl;
 
-       ParticleManager particleManager;
-       VerletPhysics physics;
-       float rotX, rotY, zoom = 200;
-       float transX, transY;
-       AABB boundingBox;
-       
        PFont defFont;
 
-       class GLRenderer implements GLEventListener { 
-                 GL gl; 
-                
-                 public void init(GLAutoDrawable drawable) { 
-                   this.gl = drawable.getGL(); 
-                   gl.glClearColor(1, 0, 0, 0);    
-                   canvas.setLocation(100, 80);     
-                 } 
-                
-                 public void display(GLAutoDrawable drawable) { 
-                   gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT 
); 
-                   gl.glColor3f(1, 1, 1);  
-                   gl.glRectf(-0.8f, 0.8f, frameCount%100/100f -0.8f, 0.7f); 
-                 } 
-                
-                 public void reshape(GLAutoDrawable drawable, int x, int y, 
int width, int height) { 
-                 } 
-                
-                 public void displayChanged(GLAutoDrawable drawable, boolean 
modeChanged, boolean deviceChanged) { 
-                 } 
+       class GLRenderer implements GLEventListener {
+               GL gl;
+
+               public void init(GLAutoDrawable drawable) {
+                       this.gl = drawable.getGL();
+                       gl.glClearColor(1, 0, 0, 0);
+                       canvas.setLocation(100, 80);
                }
-       
-       
+
+               public void display(GLAutoDrawable drawable) {
+                       gl.glClear(GL.GL_COLOR_BUFFER_BIT | 
GL.GL_DEPTH_BUFFER_BIT);
+                       gl.glColor3f(1, 1, 1);
+                       gl.glRectf(-0.8f, 0.8f, frameCount % 100 / 100f - 0.8f, 
0.7f);
+               }
+
+               public void reshape(GLAutoDrawable drawable, int x, int y, int 
width,
+                               int height) {
+               }
+
+               public void displayChanged(GLAutoDrawable drawable,
+                               boolean modeChanged, boolean deviceChanged) {
+               }
+       }
+
        public void setup() {
                System.out.println("%%%%%%%%%%%%% Setup called for P5");
                /* setup p5 */
@@ -156,12 +159,18 @@
                hint(ENABLE_OPENGL_4X_SMOOTH);
                hint(ENABLE_NATIVE_FONTS);
                noStroke();
+               frameRate(FRAME_RATE);
 
-               frameRate(30);
-               
-               defFont = createFont("SansSerif", 32);
+               defFont = createFont("SansSerif", fontSize);
                textFont(defFont);
 
+               // Particle simulator
+               physics = new VerletPhysics();
+               physics.friction = 1000;
+               AABB boundingBox = new AABB(new Vec3D(0, 0, 0), new Vec3D(width,
+                               height, height));
+               physics.worldBounds = boundingBox;
+
                // Convert views to drawable
                final List<View<CyNode>> nodeViews = view.getNodeViews();
                nodes = new CyDrawable[nodeViews.size()];
@@ -172,39 +181,68 @@
                edges = new CyDrawable[edgeViews.size()];
                for (int i = 0; i < edges.length; i++)
                        edges[i] = edgeRenderer.render(edgeViews.get(i));
-               
-               
+
+               numP = nodes.length;
+               particleManager = new ParticleManager(numP, this, physics);
+
                System.out.println("%%%%%%%%%%%%% Setup DONE for P5");
        }
 
+       private int numP;
+
        public void draw() {
-               background(240);
+               background(0);
+               physics.update();
                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);
+
+               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 + translateX, -height / 2 + translateY, 
-height / 2);
-               beginGL();
+               translate(-width / 2 + translateX, -height / 2 + translateY,
+                               -height / 2);
+               
                for (CyDrawable node : nodes)
                        node.draw();
-               
+
                for (CyDrawable edge : edges)
                        edge.draw();
-               endGL();
+
+               //particleManager.draw(gl);
+
+               camera();
+               beginGL();
+               gl.glClear(javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT);
+               ((PGraphicsOpenGL)g).endGL();
+                                       
+               // 2D OpenGL UI
+               drawOverlay();
+       }
+
+       private void drawOverlay() {
+               fill(255, 255, 255, 90);
+               noStroke();
+               rect(10, height - 100, width-20, 90);
+               fill(255, 255, 255, 230);
+               text("Processing Renderer", 30, height-90+fontSize);
                
-               fill(200, 0, 0);
-               text("Cytoscape Test", 100, 100, 0);
-               
+               fill(255, 255, 255, 90);
+               stroke(100, 100, 100, 200);
+               rect(10, 10, width-20, 30);
+               noStroke();
+               fill(255, 0, 0, 90);
+               rect(11, 11, width/3, 29);
+
        }
+       
+       
 
        public void beginGL() {
                pgl = (PGraphicsOpenGL) g;
@@ -218,6 +256,7 @@
 
        float translateX = 0;
        float translateY = 0;
+
        public void mouseDragged() {
                if (mouseButton == RIGHT) {
                        rotX += (mouseX - pmouseX) * 0.01;
@@ -226,22 +265,22 @@
                        translateX += (mouseX - pmouseX) * 2;
                        translateY += (mouseY - pmouseY) * 2;
                }
-//             else if (mouseButton == LEFT) {
-//                     
-//             }
+               // else if (mouseButton == LEFT) {
+               //                      
+               // }
        }
-       
+
        public void mousePressed() {
-               if(mouseButton != CENTER) return;
-               
+               if (mouseButton != CENTER)
+                       return;
+
                System.out.println("===Mouse Click");
-               for(int i=0; i<nodes.length; i++) {
-                       if(nodes[i] instanceof Pickable) {
+               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/particle/ParticleManager.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleManager.java
    2009-08-01 01:16:07 UTC (rev 17651)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleManager.java
    2009-08-01 01:30:19 UTC (rev 17652)
@@ -52,24 +52,11 @@
                                indexBuffer.put(i * 2 + 1, rndChild);
                                VerletSpring newSpring = new 
VerletSpring(physics.particles
                                                .get(rndChild), newParticle, 
REST_LENGTH, 0.5f);
-                               // VerletConstrainedSpring2D newSpring = new
-                               // 
VerletConstrainedSpring2D(physics.particles.get(rndChild),
-                               // newParticle, REST_LENGTH, 0.5)
-                               // newSpring.limit = 0.5;
                                physics.addSpring(newSpring);
                        }
 
                }
 
-//             for (int i = 0; i < numP; i++) {
-//                     VerletParticle p = physics.particles.get(i);
-//                     for (int j = i + 1; j < numP; j++) {
-//                             VerletParticle prevP = physics.particles.get(j);
-//                             // physics.addSpring(new 
VerletMinDistanceSpring(prevP, p,
-//                             // REST_LENGTH+100, 0.5));
-//                     }
-//             }
-
                int numberElements = numP * 3;
                pointBuffer = ByteBuffer.allocateDirect(4 * 
numberElements).order(
                                ByteOrder.nativeOrder()).asFloatBuffer();
@@ -100,26 +87,4 @@
                
                gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
        }
-       
-       private void drawPolygon(GL gl, int vIdx0, int vIdx1, int vIdx2, int 
vIdx3)
-         // the polygon verticies come from the verts[] array
-         {
-           gl.glBegin(GL.GL_POLYGON);
-             gl.glVertex3f( verts[vIdx0][0], verts[vIdx0][1], verts[vIdx0][2] 
);
-             gl.glVertex3f( verts[vIdx1][0], verts[vIdx1][1], verts[vIdx1][2] 
);
-             gl.glVertex3f( verts[vIdx2][0], verts[vIdx2][1], verts[vIdx2][2] 
);
-             gl.glVertex3f( verts[vIdx3][0], verts[vIdx3][1], verts[vIdx3][2] 
);
-           gl.glEnd();
-         }
-       
-       private static final float[][] verts = { 
-                    {-1.0f,-1.0f, 1.0f},  // vertex 0
-                    {-1.0f, 1.0f, 1.0f},  // 1
-                    { 1.0f, 1.0f, 1.0f},  // 2
-                    { 1.0f,-1.0f, 1.0f},  // 3
-                    {-1.0f,-1.0f,-1.0f},  // 4
-                    {-1.0f, 1.0f,-1.0f},  // 5
-                    { 1.0f, 1.0f,-1.0f},  // 6
-                    { 1.0f,-1.0f,-1.0f},  // 7
-                 };
 }
\ No newline at end of file

Added: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/CyQuad.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/CyQuad.java
                                (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/CyQuad.java
        2009-08-01 01:30:19 UTC (rev 17652)
@@ -0,0 +1,50 @@
+package org.cytoscape.view.presentation.processing.internal.shape;
+
+import java.util.List;
+import java.util.Set;
+
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.presentation.processing.CyDrawable;
+import org.cytoscape.view.presentation.processing.Pickable;
+
+import toxi.geom.Quad;
+import toxi.geom.Vec3D;
+
+public class CyQuad extends Quad implements CyDrawable, Pickable {
+
+       public CyQuad(Vec3D[] vertices, int vertOffset) {
+               super(vertices, vertOffset);
+               // TODO Auto-generated constructor stub
+       }
+
+       public void draw() {
+               // TODO Auto-generated method stub
+               
+       }
+
+       public List<CyDrawable> getChildren() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public Set<Class<?>> getCompatibleModels() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public void setContext(View<?> viewModel) {
+
+               
+       }
+
+       public boolean isPicked() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public void pick(float x, float y) {
+               // TODO Auto-generated method stub
+               
+       }
+
+}

Added: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Rectangle.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Rectangle.java
                             (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Rectangle.java
     2009-08-01 01:30:19 UTC (rev 17652)
@@ -0,0 +1,51 @@
+package org.cytoscape.view.presentation.processing.internal.shape;
+
+import java.util.List;
+import java.util.Set;
+
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.presentation.processing.CyDrawable;
+import org.cytoscape.view.presentation.processing.Pickable;
+
+import processing.core.PApplet;
+
+import toxi.geom.Vec3D;
+
+public class Rectangle extends Vec3D implements CyDrawable, Pickable {
+       
+private PApplet p;
+       
+       private float size;
+       private int r, g, b, alpha;
+
+       public void draw() {
+               // TODO Auto-generated method stub
+               
+       }
+
+       public List<CyDrawable> getChildren() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public Set<Class<?>> getCompatibleModels() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public void setContext(View<?> viewModel) {
+               // TODO Auto-generated method stub
+               
+       }
+
+       public boolean isPicked() {
+               // TODO Auto-generated method stub
+               return false;
+       }
+
+       public void pick(float x, float y) {
+               // TODO Auto-generated method stub
+               
+       }
+
+}


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