Author: kono
Date: 2009-07-30 11:35:16 -0700 (Thu, 30 Jul 2009)
New Revision: 17629

Added:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawableManager.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/EdgeItem.java
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/CyDrawableFactory.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5EdgeRenderer.java
   
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/ProcessingPresentationFactory.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/internal/shape/Line.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/CyDrawable.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawable.java
   2009-07-30 17:54:50 UTC (rev 17628)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawable.java
   2009-07-30 18:35:16 UTC (rev 17629)
@@ -3,6 +3,8 @@
 import java.util.List;
 import java.util.Set;
 
+import org.cytoscape.view.model.View;
+
 public interface CyDrawable {
        
        /**
@@ -11,6 +13,8 @@
         */
        public void draw();
        
+       public void setContext(View<?> viewModel);
+       
        /**
         * Get all children of this drawable.
         * These visual objects will be painted automatically if draw() is 
called.

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawableFactory.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawableFactory.java
    2009-07-30 17:54:50 UTC (rev 17628)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawableFactory.java
    2009-07-30 18:35:16 UTC (rev 17629)
@@ -2,10 +2,4 @@
 
 public interface CyDrawableFactory {
 
-       public void registerDrawable(Class<? extends CyDrawable> drawable,
-                       String displayName);
-       
-       public CyDrawable getDrawable(Class<? extends CyDrawable> drawable);
-       
-       
 }

Copied: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawableManager.java
 (from rev 17512, 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawableFactory.java)
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawableManager.java
                            (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawableManager.java
    2009-07-30 18:35:16 UTC (rev 17629)
@@ -0,0 +1,11 @@
+package org.cytoscape.view.presentation.processing;
+
+public interface CyDrawableManager {
+
+       public void registerDrawable(Class<? extends CyDrawable> drawable,
+                       String displayName);
+       
+       public CyDrawable getDrawable(Class<? extends CyDrawable> drawable);
+       
+       
+}

Added: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/EdgeItem.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/EdgeItem.java
                             (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/EdgeItem.java
     2009-07-30 18:35:16 UTC (rev 17629)
@@ -0,0 +1,8 @@
+package org.cytoscape.view.presentation.processing;
+
+import org.cytoscape.view.model.View;
+
+public interface EdgeItem {
+       public void setSource(View<?> sourceView);
+       public void setTarget(View<?> targetView);
+}

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5EdgeRenderer.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5EdgeRenderer.java
      2009-07-30 17:54:50 UTC (rev 17628)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/P5EdgeRenderer.java
      2009-07-30 18:35:16 UTC (rev 17629)
@@ -1,17 +1,19 @@
 package org.cytoscape.view.presentation.processing.internal;
 
-import static 
org.cytoscape.view.presentation.processing.visualproperty.ProcessingVisualLexicon.*;
+import static 
org.cytoscape.view.presentation.processing.visualproperty.ProcessingVisualLexicon.EDGE_STYLE;
 import static 
org.cytoscape.view.presentation.property.ThreeDVisualLexicon.NODE_Z_LOCATION;
-import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_COLOR;
+import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.EDGE_COLOR;
 import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_X_LOCATION;
 import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_Y_LOCATION;
 
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNode;
+import org.cytoscape.view.model.CyNetworkView;
 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.EdgeItem;
 import org.cytoscape.view.presentation.processing.internal.shape.Cube;
 import org.cytoscape.view.presentation.processing.internal.shape.Line;
 import org.cytoscape.view.presentation.property.BasicVisualLexicon;
@@ -24,8 +26,11 @@
        
        private final VisualLexicon nodeLexicon;
        
-       public P5EdgeRenderer(PApplet p) {
+       private CyNetworkView networkView;
+       
+       public P5EdgeRenderer(PApplet p, CyNetworkView networkView) {
                this.p = p;
+               this.networkView = networkView;
                nodeLexicon = buildLexicon();
        }
        
@@ -55,20 +60,20 @@
        public CyDrawable render(View<CyEdge> view) {
                CyDrawable style = view.getVisualProperty(EDGE_STYLE);
                
-               if(style == null) 
+               if(style == null || (style instanceof EdgeItem) == false) 
                        style = new Line(p);
                
-               view.getSource().getSource();
-               view.getSource().getTarget();
+               // Extract source & target views
+               final CyNode source = view.getSource().getSource();
+               final CyNode target = view.getSource().getTarget();
+               View<CyNode> sourceView = networkView.getNodeView(source);
+               View<CyNode> targetView = networkView.getNodeView(target);
                
+               ((EdgeItem)style).setSource(sourceView);
+               ((EdgeItem)style).setTarget(targetView);
                
-               Cube cube = (Cube) style;
-               cube.x = view.getVisualProperty(NODE_X_LOCATION).floatValue();
-               cube.y = view.getVisualProperty(NODE_Y_LOCATION).floatValue();
-               cube.z = view.getVisualProperty(NODE_Z_LOCATION).floatValue();
+               style.setContext(view);
                
-               return cube;
+               return style;
        }
-
-
 }

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 17:54:50 UTC (rev 17628)
+++ 
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)
@@ -1,19 +1,15 @@
 package org.cytoscape.view.presentation.processing.internal;
 
-import static 
org.cytoscape.view.presentation.property.ThreeDVisualLexicon.NODE_Z_LOCATION;
-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 static 
org.cytoscape.view.presentation.processing.visualproperty.ProcessingVisualLexicon.*;
+import static 
org.cytoscape.view.presentation.processing.visualproperty.ProcessingVisualLexicon.NODE_STYLE;
+import static org.cytoscape.view.presentation.property.ThreeDVisualLexicon.*;
 
-import org.cytoscape.view.presentation.processing.internal.shape.Cube;
-import 
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;
@@ -40,9 +36,8 @@
                System.out.println("%%%%%%%%%%%%% Building VP2");
                //sub.addVisualProperty(ProcessingVisualLexicon.NODE_STYLE);
                
-//             sub.addVisualProperty(NODE_X_SIZE);
-//             sub.addVisualProperty(NODE_Y_SIZE);
-//             sub.addVisualProperty(NODE_Z_SIZE);
+               sub.addVisualProperty(NODE_X_SIZE);
+               sub.addVisualProperty(NODE_Y_SIZE);
                System.out.println("%%%%%%%%%%%%% Building VP3");
                
                return sub;
@@ -53,17 +48,16 @@
        }
 
        public CyDrawable render(View<CyNode> view) {
+               // 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);
+                       style = new Cube(p, nodeLexicon);
                
-               Cube cube = (Cube) style;
-               cube.x = view.getVisualProperty(NODE_X_LOCATION).floatValue();
-               cube.y = view.getVisualProperty(NODE_Y_LOCATION).floatValue();
-               cube.z = view.getVisualProperty(NODE_Z_LOCATION).floatValue();
+               style.setContext(view);
                
-               return cube;
+               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 17:54:50 UTC (rev 17628)
+++ 
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)
@@ -10,6 +10,9 @@
 import java.util.Properties;
 
 import javax.media.opengl.GL;
+import javax.media.opengl.GLAutoDrawable;
+import javax.media.opengl.GLCanvas;
+import javax.media.opengl.GLEventListener;
 import javax.swing.Icon;
 
 import org.cytoscape.model.CyEdge;
@@ -24,7 +27,10 @@
 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;
@@ -48,7 +54,10 @@
        private CyDrawable[] nodes;
        private CyDrawable[] edges;
 
-       private P5NodeRenderer nodeRenderer;
+       private final P5NodeRenderer nodeRenderer;
+       private final P5EdgeRenderer edgeRenderer;
+       
+       private GLCanvas canvas;
 
        /**
         * Constructor. Create a PApplet component based on the size given as
@@ -58,17 +67,14 @@
         */
        public ProcessingNetworkRenderer(Dimension size, CyNetworkView view) {
                System.out.println("%%%%%%%%%%%%% Constructor called for P5");
-               try {
-                       this.windowSize = size;
-                       System.out.println("%%%%%%%%%%%%% Constructor called 
for P5: 1");
-                       this.view = view;
-                       System.out.println("%%%%%%%%%%%%% Constructor called 
for P5: 2");
-                       this.nodeRenderer = new P5NodeRenderer(this);
-                       System.out.println("%%%%%%%%%%%%% Constructor called 
for P5: 3");
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
 
+               this.windowSize = size;
+               System.out.println("%%%%%%%%%%%%% Constructor called for P5: 
1");
+               this.view = view;
+               System.out.println("%%%%%%%%%%%%% Constructor called for P5: 
2");
+               this.nodeRenderer = new P5NodeRenderer(this);
+               this.edgeRenderer = new P5EdgeRenderer(this, view);
+
                System.out.println("\n\n\n\n\n\n!!!!!!!!!! Calling constructor: 
");
        }
 
@@ -108,9 +114,34 @@
        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) { 
+                 } 
+               }
+       
+       
        public void setup() {
                System.out.println("%%%%%%%%%%%%% Setup called for P5");
                /* setup p5 */
@@ -118,44 +149,58 @@
                hint(ENABLE_OPENGL_4X_SMOOTH);
                hint(ENABLE_NATIVE_FONTS);
                noStroke();
+
+               frameRate(30);
                
-               frameRate(30);
+               defFont = createFont("SansSerif", 32);
+               textFont(defFont);
 
                // Convert views to drawable
                final List<View<CyNode>> nodeViews = view.getNodeViews();
                nodes = new CyDrawable[nodeViews.size()];
-               for (int i = 0; i < nodes.length; i++) {
+               for (int i = 0; i < nodes.length; i++)
                        nodes[i] = nodeRenderer.render(nodeViews.get(i));
-               }
 
                final List<View<CyEdge>> edgeViews = view.getEdgeViews();
                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");
        }
 
        public void draw() {
-               background(0);
+               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);
+               
                translate(width / 2, height / 2, height / 2);
                rotateX(rotY);
                rotateY(rotX);
-               translate(-width / 2, -height / 2, -height / 2);
-               beginGL();              
+               translate(-width / 2 + transX, -height / 2 + transY, -height / 
2);
+               beginGL();
                for (CyDrawable node : nodes)
                        node.draw();
-
-               // for(CyDrawable edge: edges)
-               // edge.draw();
                
+               for (CyDrawable edge : edges)
+                       edge.draw();
                endGL();
                
+               fill(200, 0, 0);
+               text("Cytoscape Test", 100, 100, 0);
                
-
        }
 
        public void beginGL() {

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-30 17:54:50 UTC (rev 17628)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingPresentationFactory.java
       2009-07-30 18:35:16 UTC (rev 17629)
@@ -51,12 +51,15 @@
                                        "Cannot create presentation for null 
view model.");
 
                System.out.println("\n\n\n\n\n!!!!!!!!!! Calling: ");
+               
 
-               final JFrame frame = (JFrame) target;
-
                final ProcessingNetworkRenderer rend = new 
ProcessingNetworkRenderer(
                                DEFAULT_WINDOW_SIZE, (CyNetworkView) view);
                rend.init();
+               
+               if(target instanceof JFrame == false) return rend;
+               
+               final JFrame frame = (JFrame) target;
                System.out.println("\n\n\n\n\n!!!!!!!!!! Init Done! ");
                
                EventQueue.invokeLater(new Runnable() {

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 17:54:50 UTC (rev 17628)
+++ 
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)
@@ -3,23 +3,23 @@
 import static 
org.cytoscape.view.presentation.property.ThreeDVisualLexicon.NODE_Z_LOCATION;
 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_X_SIZE;
 import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_Y_LOCATION;
 
+import java.awt.Color;
+import java.awt.Paint;
 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.Vec3D;
 
 /**
@@ -33,56 +33,27 @@
        private static final long serialVersionUID = -3971892445041605908L;
        private static final String DISPLAY_NAME = "Cube";
        
-       private ProcessingVisualLexicon lexicon;
+       private static final int DEF_SIZE = 20;
        
        private Set<Class<?>> compatibleDataType;
        
-       private static VisualLexicon sub;
+       private final VisualLexicon lexicon;
        
-       static {
-               sub = new BasicVisualLexicon();
-               sub.addVisualProperty(NODE_COLOR);
-               sub.addVisualProperty(NODE_X_LOCATION);
-               sub.addVisualProperty(NODE_Y_LOCATION);
-               sub.addVisualProperty(NODE_Z_LOCATION);
-       }
-       
-       
        private PApplet p;
-       private GL gl;
-       private PGraphicsOpenGL pgl;
        
-       
        private float size;
-       private float r, g, b, alpha;
+       private int r, g, b, alpha;
         
        
-       public Cube(PApplet parent) {
+       public Cube(PApplet parent, VisualLexicon lexicon) {
                super();
                this.p = parent;
-               size = 20;
-       }
-       
-       public Cube(ProcessingVisualLexicon lexicon) {
-               
                this.lexicon = lexicon;
+               
                compatibleDataType = new HashSet<Class<?>>();
                compatibleDataType.add(CyNode.class);
-               
-               this.lexicon.registerSubLexicon(this.getClass(), sub);
-               
-               r = 100;
-               g = 200;
-               b = 100;
-               alpha = 150;
-               
-               this.rotateX(p.random(p.PI));
-               this.rotateY(p.random(p.PI));
-               this.rotateZ(p.random(p.PI));
        }
 
-
-
        public Set<Class<?>> getCompatibleModels() {
                return compatibleDataType;
        }
@@ -96,13 +67,11 @@
                return null;
        }
 
-       public VisualLexicon getCompatibleVisualProperties() {
-               return lexicon.getSubLexicon(this.getClass());
-       }
-
        public void draw() {
                p.pushMatrix();
                p.translate(x, y, z);
+               p.fill(r, g, b, alpha);
+               //p.fill(204, 102, 0);
                p.box(size);
                p.popMatrix();
        }
@@ -112,4 +81,27 @@
                return null;
        }
 
+       public void setContext(View<?> viewModel) {
+               // Pick compatible lexicon only.
+               this.x = 
viewModel.getVisualProperty(NODE_X_LOCATION).floatValue();
+               this.y = 
viewModel.getVisualProperty(NODE_Y_LOCATION).floatValue();
+               this.z = 
viewModel.getVisualProperty(NODE_Z_LOCATION).floatValue();
+               
+               this.size = 
viewModel.getVisualProperty(NODE_X_SIZE).floatValue();
+               if(size <= 0)
+                       size = DEF_SIZE;
+               
+               Paint color = viewModel.getVisualProperty(NODE_COLOR);
+               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);
+               }
+               
+               
+       }
+
 }

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Line.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Line.java
  2009-07-30 17:54:50 UTC (rev 17628)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Line.java
  2009-07-30 18:35:16 UTC (rev 17629)
@@ -1,22 +1,27 @@
 package org.cytoscape.view.presentation.processing.internal.shape;
 
+import static org.cytoscape.view.presentation.property.ThreeDVisualLexicon.*;
 import java.awt.Color;
+import java.awt.Paint;
 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.EdgeItem;
 
 import processing.core.PApplet;
 import toxi.geom.Vec3D;
 
-public class Line implements CyDrawable {
+public class Line implements CyDrawable, EdgeItem {
        
        private final PApplet p;
        
+       // Start and end point of this line.
        private Vec3D source;
        private Vec3D target;
        
-       private Color color;
+       private int r, g, b, alpha;
        
        public Line(PApplet p) {
                this.p = p;
@@ -25,7 +30,7 @@
        }
 
        public void draw() {
-               p.stroke(color.getRed(), color.getGreen(), color.getBlue(), 
color.getAlpha());
+               p.stroke(r, g, b, alpha);
                p.line(source.x, source.y, source.z, target.x, target.y, 
target.z);             
        }
 
@@ -39,4 +44,29 @@
                return null;
        }
 
+       public void setContext(View<?> viewModel) {
+               Paint edgePaint = viewModel.getVisualProperty(EDGE_COLOR);
+               
+               if(edgePaint instanceof Color) {
+                       this.r = ((Color)edgePaint).getRed();
+                       this.g = ((Color)edgePaint).getGreen();
+                       this.b = ((Color)edgePaint).getBlue();
+                       this.alpha = ((Color)edgePaint).getAlpha();
+                       
+                       System.out.println("Color of Edge = " + r +", " + g + 
", " + b + ", alpha = " + alpha);
+               }
+       }
+
+       public void setSource(View<?> sourceView) {
+               source.x = 
sourceView.getVisualProperty(NODE_X_LOCATION).floatValue();
+               source.y = 
sourceView.getVisualProperty(NODE_Y_LOCATION).floatValue();
+               source.z = 
sourceView.getVisualProperty(NODE_Z_LOCATION).floatValue();
+       }
+
+       public void setTarget(View<?> targetView) {
+               target.x = 
targetView.getVisualProperty(NODE_X_LOCATION).floatValue();
+               target.y = 
targetView.getVisualProperty(NODE_Y_LOCATION).floatValue();
+               target.z = 
targetView.getVisualProperty(NODE_Z_LOCATION).floatValue();
+       }
+
 }


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