Author: kono
Date: 2009-07-20 20:07:00 -0700 (Mon, 20 Jul 2009)
New Revision: 17497

Added:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/Particle2D.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleGL2D.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleManager2D.java
Modified:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/osgi.bnd
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawable.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/CreatePresentationTask.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/CyDrawableFactoryImpl.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/GestaltFactoryImpl.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NodePresentation.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/ProcessingPresentationFactory.java
   
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/shape/GCube.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/GLPoint.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/ShapeFactory.java
Log:
CyDrawable refactored to extend anything.

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/osgi.bnd
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/osgi.bnd
   2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/osgi.bnd
   2009-07-21 03:07:00 UTC (rev 17497)
@@ -3,7 +3,7 @@
 #-----------------------------------------------------------------
 
 Export-Package: org.cytoscape.view.presentation.processing
-Import-Package: processing.core.*, *;resolution:=optional
+Import-Package: processing.*, *;resolution:=optional
 
 DynamicImport-Package: *
 

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawable.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawable.java
   2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawable.java
   2009-07-21 03:07:00 UTC (rev 17497)
@@ -1,29 +1,32 @@
 package org.cytoscape.view.presentation.processing;
 
-import gestalt.render.Drawable;
+import java.util.List;
+import java.util.Set;
 
-import java.util.Collection;
-
 import javax.swing.Icon;
 
-public interface CyDrawable extends Drawable {
+public interface CyDrawable {
        
+       public void draw();
+       
+       public List<CyDrawable> getChildren();
+
        /**
-        * Name of this object.  Can be anything.
+        * Name of this object. Can be anything.
         * 
         * @return Name of shape as string
         * 
         */
        public String getDisplayName();
-       
+
        /**
-        * Get compatible data type.
-        * For example, if this object accepts CyNode, return the collection 
with CyNode class.
+        * Get compatible data type. For example, if this object accepts CyNode,
+        * return the collection with CyNode class.
         * 
         * @return set of compatible data types.
         */
-       public Collection<Class<?>> getCompatibleModels();
-       
+       public Set<Class<?>> getCompatibleModels();
+
        // Render Icon based on current state
        public Icon getIcon(int width, int height);
 

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/CreatePresentationTask.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/CreatePresentationTask.java
      2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/CreatePresentationTask.java
      2009-07-21 03:07:00 UTC (rev 17497)
@@ -31,9 +31,9 @@
        public void run(TaskMonitor taskMonitor) throws Exception {
                // TODO Auto-generated method stub
                
-               this.taskMonitor = taskMonitor;
-               taskMonitor.setProgress(-1.0);
-               taskMonitor.setStatusMessage("Creating Processing 
Presentation...");
+//             this.taskMonitor = taskMonitor;
+//             taskMonitor.setProgress(-1.0);
+//             taskMonitor.setStatusMessage("Creating Processing 
Presentation...");
                
                CyNetwork targetNetwork = manager.getCurrentNetwork();
                System.out.println("* Creating Processing presentation for: " + 
targetNetwork);
@@ -43,9 +43,7 @@
                
                System.out.println("=======> Presentation OK");
                
-               taskMonitor.setProgress(1.0);
-               
-
+               //taskMonitor.setProgress(1.0);
        }
 
 }

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/CyDrawableFactoryImpl.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/CyDrawableFactoryImpl.java
       2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/CyDrawableFactoryImpl.java
       2009-07-21 03:07:00 UTC (rev 17497)
@@ -2,9 +2,12 @@
 
 import gestalt.impl.jogl.shape.JoglDrawableFactory;
 import gestalt.render.Drawable;
+import gestalt.shape.Cube;
 
+import org.cytoscape.view.presentation.processing.internal.shape.GCube;
 
 
+
 /**
  * Factory for shapes.
  * 
@@ -21,5 +24,10 @@
        public Drawable getDrawable(Class<? extends Drawable> type) {
                return null;
        }
+       
+       public Cube cube() {
+               System.out.println("@@@@@@@@@@ GCube");
+               return null;
+       }
 
 }

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/GestaltFactoryImpl.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/GestaltFactoryImpl.java
  2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/GestaltFactoryImpl.java
  2009-07-21 03:07:00 UTC (rev 17497)
@@ -1,6 +1,5 @@
 package org.cytoscape.view.presentation.processing.internal;
 
-import gestalt.render.Drawable;
 import gestalt.shape.DrawableFactory;
 
 import org.cytoscape.view.model.View;

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NodePresentation.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NodePresentation.java
  2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5NodePresentation.java
  2009-07-21 03:07:00 UTC (rev 17497)
@@ -1,5 +1,8 @@
 package org.cytoscape.view.presentation.processing.internal;
 
+import gestalt.context.GLContext;
+import gestalt.extension.picking.Pickable;
+
 import java.awt.Component;
 import java.awt.Image;
 import java.awt.print.Printable;
@@ -7,9 +10,6 @@
 
 import javax.swing.Icon;
 
-import gestalt.context.GLContext;
-import gestalt.extension.picking.Pickable;
-
 import org.cytoscape.model.CyNode;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualLexicon;

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-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   2009-07-21 03:07:00 UTC (rev 17497)
@@ -1,35 +1,30 @@
 package org.cytoscape.view.presentation.processing.internal;
 
-import gestalt.Gestalt;
-import gestalt.context.GLContext;
-import gestalt.p5.GestaltPlugIn;
 import gestalt.render.Drawable;
-import gestalt.render.bin.RenderBin;
-import gestalt.shape.AbstractDrawable;
-import gestalt.shape.Cube;
-import gestalt.shape.Plane;
 
 import java.awt.Component;
-import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.Image;
 import java.awt.print.Printable;
-import java.util.List;
 import java.util.Properties;
 
 import javax.media.opengl.GL;
-import javax.media.opengl.glu.GLU;
 import javax.swing.Icon;
 
 import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualLexicon;
 import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.presentation.processing.CyDrawable;
 import org.cytoscape.view.presentation.processing.P5Renderer;
+import 
org.cytoscape.view.presentation.processing.internal.particle.ParticleManager;
+import org.cytoscape.view.presentation.processing.internal.shape.GCube;
 
 import processing.core.PApplet;
+import processing.opengl.PGraphicsOpenGL;
+import toxi.geom.AABB;
+import toxi.geom.Vec3D;
+import toxi.physics.VerletPhysics;
 
 public class ProcessingNetworkRenderer extends PApplet implements
                P5Renderer<CyNetwork> {
@@ -44,24 +39,21 @@
        private Dimension windowSize;
        private View<CyNetwork> view;
 
-
-       // Gestalt plugin
-       private GestaltPlugIn gestalt;
-
-       //
        GraphRenderer renderer;
-       
-       Drawable[] nodes; 
 
+       Drawable[] nodes;
+
        /**
         * Constructor. Create a PApplet component based on the size given as
         * parameter.
         * 
         * @param size
         */
-       public ProcessingNetworkRenderer(Container parent, View<CyNetwork> 
view) {
+       public ProcessingNetworkRenderer(Dimension size, View<CyNetwork> view) {
+               this.windowSize = size;
                this.view = view;
-               this.windowSize = parent.getSize();
+               System.out.println("%%%%%%%%%%%%% Constructor called for P5");
+               System.out.println("\n\n\n\n\n\n!!!!!!!!!! Calling constructor: 
");
        }
 
        public Image getImage(int width, int height) {
@@ -94,144 +86,76 @@
                return null;
        }
        
-       private Cube _myPlaneIn3D;
+       
+       
+       PGraphicsOpenGL pgl;
+       GL gl;
 
-    private Plane _myPlaneIn2D;
-
-    public void setup() {
-        /* setup p5 */
-        size(1900, 1000, OPENGL);
-        rectMode(CENTER);
-        stroke(122);
-
-        gestalt = new GestaltPlugIn(this);
-        gestalt.setDrawablefactoryRef(new CyDrawableFactoryImpl());
-        
-        
-        nodes = new Drawable[view.getSource().getNodeCount()];
-               CyNetwork net = view.getSource();
-               List<CyNode> nodeList = net.getNodeList();
-               int i = 0;
-               Cube cube;
-               for(CyNode node: nodeList) {
-                       cube = gestalt.drawablefactory().cube();
-                       cube.position().x = width/2+random(0, width);
-               cube.position().y = height/2+random(0, height);
-               cube.position().z = random(-1500, 1500);
-               cube.rotation(random(0, 10), random(0, 10), random(0, 10));
-               cube.scale(random(30, 100), random(30, 100), random(30, 100));
-               cube.material().getColor().set(random(0, 1), random(0, 1), 
random(0, 1), random(0, 1));
-               cube.material().lit = true;
-//             cube.material().wireframe = true;
-               gestalt.bin(Gestalt.BIN_3D).add(cube);
-               i++;
-               }
-
-        /* create planes */
-        _myPlaneIn3D = gestalt.drawablefactory().cube();
-        _myPlaneIn3D.scale().x = 50;
-        _myPlaneIn3D.scale().y = 150;
-        
-        gestalt.bin(Gestalt.BIN_3D).add(_myPlaneIn3D);
-
-        _myPlaneIn2D = gestalt.drawablefactory().plane();
-        _myPlaneIn2D.scale().x = 50;
-        _myPlaneIn2D.scale().y = 150;
-       
-        gestalt.bin(Gestalt.BIN_2D_FOREGROUND).add(_myPlaneIn2D);
-
-        gestalt.light().enable = true;
-        gestalt.light().position().set(width/2, height/2, 23);
-        gestalt.light().diffuse.set(1, 1, 1, 1);
-        gestalt.light().ambient.set(0, 0, 0, 1);
-        
-        /* camera() */
-//        gestalt.camera().position().set(0, 0, 2000);
-//        gestalt.camera().setMode(Gestalt.CAMERA_MODE_LOOK_AT);
-    }
-
-
-    public void draw() {
-        /* glue gestalt shapes to mouse */
-        _myPlaneIn3D.position().x = mouseX - 60;
-        _myPlaneIn3D.position().y = mouseY;
-
-        _myPlaneIn2D.position().x = mouseX + 60;
-        _myPlaneIn2D.position().y = mouseY;
-        
-        /* clear screen */
-        background(255, 128, 0);
-
-        /* draw processing shape */
-        //rect(gestalt.event().mouseX, gestalt.event().mouseY, 50, 150);
-    }
+       ParticleManager particleManager;
+       VerletPhysics physics;
+       float rotX, rotY, zoom = 200;
+       AABB boundingBox;
        
-//     public void setup() {
-//             size(windowSize.width, windowSize.height, OPENGL);
-////           hint(ENABLE_OPENGL_4X_SMOOTH);
-////           frameRate(30);
-////           smooth();
-//
-//             /* create gestalt plugin */
-//             gestalt = new GestaltPlugIn(this);
-//             
-//             //Set Custom DrawableFactory
-//             //gestalt.setDrawablefactoryRef(new CyDrawableFactoryImpl());
-////           Cube cube = gestalt.drawablefactory().cube();
-////           cube.scale().x = 50;
-////       cube.scale().y = 150;
-//         gestalt.bin(Gestalt.BIN_3D).add(new RawOpenGL());
-//             System.out.println(" @@@@@@@@@@ Setup is OK.");
-//             
-//     
-//     }
-//
-//     long i = 0;
-//     public void draw() {
-//             System.out.println("Loop: " + i++);
-//      
-//             background(0);
-//     }
-//
+       GCube cube;
+       
+       public void setup() {
+               System.out.println("%%%%%%%%%%%%% Setup called for P5");
+               /* setup p5 */
+               size(windowSize.width, windowSize.width, OPENGL);
+               frameRate(30);
+               
+               physics = new VerletPhysics();
+               physics.friction = 1000;
+               AABB boundingBox = new AABB(new Vec3D(0, 0, 0), new Vec3D(width,
+                               height, height));
+               physics.worldBounds = boundingBox;
+               particleManager = new ParticleManager(200, this, physics);
+               
+               cube = new GCube(this);
+               System.out.println("%%%%%%%%%%%%% Setup DONE for P5");
+       }
 
 
-       private class RawOpenGL extends AbstractDrawable {
+       public void draw() {
+               background(0);
+               physics.update();
+               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, -height / 2, -height / 2);
+               beginGL();
+               particleManager.draw(gl);
+               endGL();
+               // println(frameRate);
+               cube.draw();
+               
+               
+       }
 
-               public void draw(final GLContext theContext) {
-                       GL gl = gestalt.getGL();
-                       GLU glu = gestalt.getGLU();
+       public void beginGL() {
+               pgl = (PGraphicsOpenGL) g;
+               gl = pgl.beginGL();
+               gl.glViewport(0, 0, width, height);
+       }
 
-                       gl.glViewport(0, 0, width, height);
-                       gl.glMatrixMode(GL.GL_PROJECTION);
-                       gl.glLoadIdentity();
-                       glu
-                                       .gluPerspective(45.0f, (float) width / 
(float) height, 1.0,
-                                                       20.0);
-
-                       gl.glMatrixMode(GL.GL_MODELVIEW);
-                       gl.glLoadIdentity();
-
-                       gl.glTranslatef(-1.5f, 0.0f, -6.0f);
-                       gl.glBegin(GL.GL_TRIANGLES);
-                       gl.glColor3f(1.0f, 0.0f, 0.0f);
-                       gl.glVertex3f(0.0f, 1.0f, 0.0f);
-                       gl.glColor3f(0.0f, 1.0f, 0.0f);
-                       gl.glVertex3f(-1.0f, -1.0f, 0.0f);
-                       gl.glColor3f(0.0f, 0.0f, 1.0f);
-                       gl.glVertex3f(1.0f, -1.0f, 0.0f);
-                       gl.glEnd();
-
-                       gl.glTranslatef(3.0f, 0.0f, 0.0f);
-                       gl.glBegin(GL.GL_QUADS);
-                       gl.glColor3f(0.5f, 0.5f, 1.0f);
-                       gl.glVertex3f(-1.0f, 1.0f, 0.0f);
-                       gl.glVertex3f(1.0f, 1.0f, 0.0f);
-                       gl.glVertex3f(1.0f, -1.0f, 0.0f);
-                       gl.glVertex3f(-1.0f, -1.0f, 0.0f);
-                       gl.glEnd();
+       public void endGL() {
+               pgl.endGL();
+       }
+       
+       public void mouseDragged() {
+               if (mouseButton == RIGHT) {
+                       zoom += (mouseY - pmouseY) * 1;
+               } else if (mouseButton == LEFT) {
+                       rotX += (mouseX - pmouseX) * 0.01;
+                       rotY -= (mouseY - pmouseY) * 0.01;
                }
        }
+       
 
+
        public Icon getDefaultIcon(VisualProperty<?> vp) {
                // TODO Auto-generated method stub
                return null;
@@ -247,7 +171,7 @@
        }
 
        public View<CyNetwork> getViewModel() {
-               return view;
+               return null;
        }
 
 }

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingPresentationFactory.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingPresentationFactory.java
       2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingPresentationFactory.java
       2009-07-21 03:07:00 UTC (rev 17497)
@@ -1,20 +1,19 @@
 package org.cytoscape.view.presentation.processing.internal;
 
-import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NETWORK_TITLE;
-
 import java.awt.BorderLayout;
-import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
+import java.awt.EventQueue;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.swing.JFrame;
 
 import org.cytoscape.model.CyNetwork;
-import org.cytoscape.view.model.CyNetworkView;
 import org.cytoscape.view.model.View;
 import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.model.events.NetworkViewChangedEvent;
@@ -24,12 +23,11 @@
 import org.cytoscape.view.presentation.Renderer;
 import org.cytoscape.view.presentation.processing.P5Renderer;
 
-import processing.core.PApplet;
-
 public class ProcessingPresentationFactory implements PresentationFactory,
                NetworkViewChangedListener {
 
-       private static final Dimension DEFAULT_WINDOW_SIZE = new 
Dimension(1900, 1000);
+       private static final Dimension DEFAULT_WINDOW_SIZE = new Dimension(1200,
+                       1000);
 
        private final Map<Class<?>, Class<? extends P5Renderer<?>>> rendererMap;
 
@@ -51,76 +49,126 @@
                return null;
        }
 
-       public <T extends View<?>> Renderer<T> addPresentation(Container frame,
-                       T view) {
+       public <T extends View<?>> Renderer<T> addPresentation(
+                       final Container frame2, final T view) {
                // Check parameter
-               if (view == null)
-                       throw new IllegalArgumentException(
-                                       "Cannot create presentation for null 
view model.");
-               
-               Class<? extends P5Renderer<?>> rendererClass = null;
-               
-               for(Class<?> key :rendererMap.keySet()) {
-                       if(key.isAssignableFrom(view.getSource().getClass())) {
-                               rendererClass = rendererMap.get(key);
-                       }
-               }
-               
-               if (rendererClass == null)
-                       throw new IllegalArgumentException(
-                                       "Cannot create presentation for "
-                                                       + 
view.getSource().getClass().toString() + ":  Could not find implementation.");
+//             if (view == null)
+//                     throw new IllegalArgumentException(
+//                                     "Cannot create presentation for null 
view model.");
 
-               System.out.println("====== Creating Processing Dialog 
=========");
+               // Class<? extends P5Renderer<?>> rendererClass = null;
+               //              
+               // for(Class<?> key :rendererMap.keySet()) {
+               // if(key.isAssignableFrom(view.getSource().getClass())) {
+               // rendererClass = rendererMap.get(key);
+               // }
+               // }
+               //              
+               // if (rendererClass == null)
+               // throw new IllegalArgumentException(
+               // "Cannot create presentation for "
+               // + view.getSource().getClass().toString() +
+               // ":  Could not find implementation.");
+               //
+               // System.out.println("====== Creating Processing Dialog 
=========");
+               //
+               //              
+               //
+               // P5Renderer<?> renderer = null;
+               // try {
+               // Constructor<? extends P5Renderer<?>> ct = rendererClass
+               // .getConstructor(Container.class, View.class);
+               //                      
+               //
+               // renderer = ct.newInstance(frame, view);
+               // } catch (IllegalArgumentException e) {
+               // // TODO Auto-generated catch block
+               // e.printStackTrace();
+               // } catch (InstantiationException e) {
+               // // TODO Auto-generated catch block
+               // e.printStackTrace();
+               // } catch (IllegalAccessException e) {
+               // // TODO Auto-generated catch block
+               // e.printStackTrace();
+               // } catch (InvocationTargetException e) {
+               // // TODO Auto-generated catch block
+               // e.printStackTrace();
+               // } catch (SecurityException e) {
+               // // TODO Auto-generated catch block
+               // e.printStackTrace();
+               // } catch (NoSuchMethodException e) {
+               // // TODO Auto-generated catch block
+               // e.printStackTrace();
+               // }
+               //
+               //              
+               System.out.println("\n\n\n\n\n!!!!!!!!!! Calling: ");
 
+               System.out.println("\n\n\n\n\n!!!!!!!!!! Done! ");
+               // window.setTitle(title);
                
+//              JFrame f = (JFrame) frame;
+//              PAppletFrameListener listener = new PAppletFrameListener(rend);
+//              f.addWindowListener(listener);
 
-               P5Renderer<?> renderer = null;
-               try {
-                       Constructor<? extends P5Renderer<?>> ct = rendererClass
-                                       .getConstructor(Container.class, 
View.class);
-                       
+               show((JFrame) frame2);
 
-                       renderer = ct.newInstance(frame, view);
-               } catch (IllegalArgumentException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } catch (InstantiationException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } catch (IllegalAccessException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } catch (InvocationTargetException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } catch (SecurityException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } catch (NoSuchMethodException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
 
-               
-               ProcessingNetworkRenderer rend = new 
ProcessingNetworkRenderer(frame, (View<CyNetwork>) view);
-               // window.setTitle(title);
-               frame.setLayout(new BorderLayout());
-               frame.setSize(DEFAULT_WINDOW_SIZE);
-               frame.setPreferredSize(DEFAULT_WINDOW_SIZE);
-               frame.add(rend.getComponent(), BorderLayout.CENTER);
-               ((PApplet)rend).init();
-               ((JFrame) frame).pack();
-               
-               ((JFrame) frame).setLocationByPlatform(true);
-               ((JFrame) frame).setVisible(true);
-               ((JFrame) 
frame).setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+               //              
 
-               System.out.println(" ========= Processing Dialog Had been 
created.");
+               return null;
+               //return (Renderer<T>) rend;
+       }
+       
+       private void show(final JFrame frame) {
+               final ProcessingNetworkRenderer rend = new 
ProcessingNetworkRenderer(
+                               DEFAULT_WINDOW_SIZE, null);
+               rend.init();
+                EventQueue.invokeLater(new Runnable() {
+                   
 
-               return (Renderer<T>) rend;
+                       public void run() {
+                               // TODO Auto-generated method stub
+                               
+                               frame.setLayout(new BorderLayout());
+                               frame.setSize(DEFAULT_WINDOW_SIZE);
+                               frame.setPreferredSize(DEFAULT_WINDOW_SIZE);
+                               frame.add(rend.getComponent(), 
BorderLayout.CENTER);
+                               
+                               frame.pack();
+
+                               frame.setLocationByPlatform(true);
+                               
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+                               
+                               frame.addWindowListener(new WindowAdapter() {
+
+                           @Override
+                           public void windowClosing(WindowEvent e) {
+                               // Run this on another thread than the AWT 
event queue to
+                               // make sure the call to Animator.stop() 
completes before
+                               // exiting
+                               new Thread(new Runnable() {
+
+                                   public void run() {
+                                       System.out.println("========== P 
closed.");
+                                               rend.stop();
+                                               System.out.println("========== 
P Finished!==============");
+                                               //System.gc();
+                                   }
+                               }).start();
+                           }
+                       });
+                               
+                               
+                               frame.setVisible(true);
+                               
+                               System.out.println(" ========= Processing 
Dialog Had been created.");
+                       }
+
+               });
+               
        }
-
+       
        public void visualPropertySet(VisualProperty<?> vp, Object value) {
                // TODO Auto-generated method stub
 

Added: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/Particle2D.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/Particle2D.java
                         (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/Particle2D.java
 2009-07-21 03:07:00 UTC (rev 17497)
@@ -0,0 +1,18 @@
+package org.cytoscape.view.presentation.processing.internal.particle;
+
+import java.nio.FloatBuffer;
+
+public class Particle2D {
+
+       float posX, posY;
+
+       public Particle2D(int _id, float _posX, float _posY) {
+               posX = _posX;
+               posY = _posY;
+       }
+
+       public void writeToBuffer(FloatBuffer _buffer, int index) {
+               _buffer.put(index, posX);
+               _buffer.put(index + 1, posY);
+       }
+}

Added: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleGL2D.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleGL2D.java
                               (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleGL2D.java
       2009-07-21 03:07:00 UTC (rev 17497)
@@ -0,0 +1,41 @@
+package org.cytoscape.view.presentation.processing.internal.particle;
+
+import javax.media.opengl.GL;
+
+import processing.core.PApplet;
+import processing.opengl.PGraphicsOpenGL;
+import toxi.physics2d.VerletPhysics2D;
+
+public class ParticleGL2D extends PApplet {
+
+       PGraphicsOpenGL pgl;
+       GL gl;
+
+       ParticleManager2D particleManager;
+       VerletPhysics2D physics;
+
+       public void setup() {
+               size(1024, 600, OPENGL);
+               frameRate(30);
+               physics = new VerletPhysics2D();
+               particleManager = new ParticleManager2D(this, 10000, physics);
+       }
+
+       public void draw() {
+               background(0);
+               physics.update();
+               beginGL();
+               particleManager.manage(gl);
+               endGL();
+               // println(frameRate);
+       }
+
+       public void beginGL() {
+               pgl = (PGraphicsOpenGL) g;
+               gl = pgl.beginGL();
+       }
+
+       public void endGL() {
+               pgl.endGL();
+       }
+}
\ No newline at end of file

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-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleManager.java
    2009-07-21 03:07:00 UTC (rev 17497)
@@ -7,8 +7,9 @@
 
 import javax.media.opengl.GL;
 
+import com.sun.opengl.util.GLUT;
+
 import processing.core.PApplet;
-
 import toxi.physics.VerletParticle;
 import toxi.physics.VerletPhysics;
 import toxi.physics.VerletSpring;
@@ -89,13 +90,36 @@
                }
 
                gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
-               gl.glPointSize(6.0f);
+               gl.glPointSize(16.0f);
                gl.glVertexPointer(3, GL.GL_FLOAT, 0, pointBuffer);
                gl.glColor3f(100, 100, 100);
                gl.glDrawElements(GL.GL_LINES, numP * 2, GL.GL_UNSIGNED_INT,
                                indexBuffer);
-               gl.glColor3f(100, 50, 0);
+               gl.glColor3f(100, 50, 100);
                gl.glDrawArrays(GL.GL_POINTS, 0, numP);
+               
                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/particle/ParticleManager2D.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleManager2D.java
                          (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/particle/ParticleManager2D.java
  2009-07-21 03:07:00 UTC (rev 17497)
@@ -0,0 +1,89 @@
+package org.cytoscape.view.presentation.processing.internal.particle;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+
+import javax.media.opengl.GL;
+
+import processing.core.PApplet;
+import toxi.physics2d.VerletParticle2D;
+import toxi.physics2d.VerletPhysics2D;
+import toxi.physics2d.VerletSpring2D;
+
+public class ParticleManager2D {
+       FloatBuffer pointBuffer;
+       IntBuffer indexBuffer;
+       Particle2D particles[];
+       int numP;
+       int REST_LENGTH = 50;
+
+       VerletPhysics2D physics;
+
+       PApplet parent;
+
+       public ParticleManager2D(PApplet parent, int _numP,
+                       VerletPhysics2D physics) {
+               numP = _numP;
+               this.physics = physics;
+               this.parent = parent;
+
+               int numberIndices = numP * 2;
+               indexBuffer = ByteBuffer.allocateDirect(4 * 
numberIndices).order(
+                               ByteOrder.nativeOrder()).asIntBuffer();
+               indexBuffer.limit(numberIndices);
+               indexBuffer.rewind();
+
+               particles = new Particle2D[numP];
+               for (int i = 0; i < numP; i++) {
+                       int rndX = (int) parent.random(0, parent.width);
+                       int rndY = (int) parent.random(0, parent.height);
+                       VerletParticle2D newParticle = new 
VerletParticle2D(rndX, rndY);
+                       physics.addParticle(newParticle);
+                       particles[i] = new Particle2D(i, rndX, rndY);
+                       if (i > 0) {
+                               indexBuffer.put(i * 2, i);
+                               int rndChild = (int) parent.random(i);
+                               indexBuffer.put(i * 2 + 1, rndChild);
+                               physics.addSpring(new 
VerletSpring2D(physics.particles
+                                               .get(rndChild), newParticle, 
REST_LENGTH, 0.5f));
+                       }
+
+               }
+
+               for (int i = 0; i < numP; i++) {
+                       VerletParticle2D p = physics.particles.get(i);
+                       for (int j = i + 1; j < numP; j++) {
+                               VerletParticle2D prevP = 
physics.particles.get(j);
+                               // physics.addSpring(new 
VerletMinDistanceSpring2D(prevP, p,
+                               // REST_LENGTH, 0.5));
+                       }
+               }
+
+               int numberElements = numP * 2;
+               pointBuffer = ByteBuffer.allocateDirect(4 * 
numberElements).order(
+                               ByteOrder.nativeOrder()).asFloatBuffer();
+               pointBuffer.limit(numberElements);
+               pointBuffer.rewind();
+
+       }
+
+       public void manage(GL gl) {
+               for (int i = 0; i < numP; i++) {
+                       VerletParticle2D p = physics.particles.get(i);
+                       particles[i].posX = p.x;
+                       particles[i].posY = p.y;
+                       particles[i].writeToBuffer(pointBuffer, i * 2);
+               }
+               gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
+               gl.glPointSize(2.0f);
+               gl.glVertexPointer(2, GL.GL_FLOAT, 0, pointBuffer);
+               gl.glColor3f(0, 0, 100);
+               gl.glDrawElements(GL.GL_LINES, numP * 2, GL.GL_UNSIGNED_INT,
+                               indexBuffer);
+               gl.glColor3f(100, 10, 0);
+               gl.glDrawArrays(GL.GL_POINTS, 0, numP);
+               gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
+       }
+}

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/GCube.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/GCube.java
 2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/GCube.java
 2009-07-21 03:07:00 UTC (rev 17497)
@@ -4,35 +4,39 @@
 import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_COLOR;
 import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_X_LOCATION;
 import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_Y_LOCATION;
-import gestalt.context.GLContext;
-import gestalt.impl.jogl.shape.JoglCube;
 
-import java.util.ArrayList;
-import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
+import javax.media.opengl.GL;
 import javax.swing.Icon;
 
 import org.cytoscape.model.CyNode;
+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.visualproperty.ProcessingVisualLexicon;
 import org.cytoscape.view.presentation.property.BasicVisualLexicon;
 
+import processing.core.PApplet;
+import processing.opengl.PGraphicsOpenGL;
+import toxi.geom.Rect;
+
 /**
  * Wrapper for JOGL-based Cube object.
  * 
  * @author kono
  *
  */
-public class GCube extends JoglCube implements CyDrawable {
+public class GCube implements CyDrawable {
 
        private static final long serialVersionUID = -3971892445041605908L;
        private static final String DISPLAY_NAME = "Cube";
        
        private ProcessingVisualLexicon lexicon;
        
-       private List<Class<?>> compatibleDataType;
+       private Set<Class<?>> compatibleDataType;
        
        private static VisualLexicon sub;
        
@@ -44,20 +48,30 @@
                sub.addVisualProperty(NODE_Z_LOCATION);
        }
        
+       
+       private PApplet p;
+       private GL gl;
+       private PGraphicsOpenGL pgl;
+       
+       public GCube(PApplet parent, View<?> view) {
+               this.p = parent;
+               this.pgl = (PGraphicsOpenGL) p.g;
+               gl = pgl.gl;
+               
+       }
+       
        public GCube(ProcessingVisualLexicon lexicon) {
-               super();
+               
                this.lexicon = lexicon;
-               compatibleDataType = new ArrayList<Class<?>>();
+               compatibleDataType = new HashSet<Class<?>>();
                compatibleDataType.add(CyNode.class);
                
                this.lexicon.registerSubLexicon(this.getClass(), sub);
        }
 
-       public void draw(GLContext context) {
-               super.draw(context);
-       }
 
-       public Collection<Class<?>> getCompatibleModels() {
+
+       public Set<Class<?>> getCompatibleModels() {
                return compatibleDataType;
        }
 
@@ -74,4 +88,13 @@
                return lexicon.getSubLexicon(this.getClass());
        }
 
+       public void draw() {
+               p.box(20);
+       }
+
+       public List<CyDrawable> getChildren() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
 }

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/GLPoint.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/GLPoint.java
       2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/GLPoint.java
       2009-07-21 03:07:00 UTC (rev 17497)
@@ -3,13 +3,11 @@
 import gestalt.context.GLContext;
 import gestalt.shape.AbstractShape;
 
-import java.util.Collection;
 import java.util.Set;
 
 import javax.swing.Icon;
 
 import org.cytoscape.view.model.VisualLexicon;
-import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.presentation.processing.CyDrawable;
 
 public class GLPoint extends AbstractShape implements CyDrawable {
@@ -17,7 +15,7 @@
        
        private static final long serialVersionUID = -7966355417706954584L;
 
-       public Collection<Class<?>> getCompatibleModels() {
+       public Set<Class<?>> getCompatibleModels() {
                // TODO Auto-generated method stub
                return null;
        }
@@ -42,5 +40,10 @@
                return null;
        }
 
+       public void draw() {
+               // 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/ShapeFactory.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/ShapeFactory.java
  2009-07-21 00:19:38 UTC (rev 17496)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/ShapeFactory.java
  2009-07-21 03:07:00 UTC (rev 17497)
@@ -1,10 +1,6 @@
 package org.cytoscape.view.presentation.processing.internal.shape;
 
-import static 
org.cytoscape.view.presentation.property.ThreeDVisualLexicon.NODE_Z_LOCATION;
-import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_X_LOCATION;
-import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_Y_LOCATION;
 import gestalt.p5.GestaltPlugIn;
-import gestalt.shape.AbstractShape;
 import gestalt.shape.DrawableFactory;
 
 import org.cytoscape.model.CyNode;


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