Author: kono
Date: 2009-08-13 17:01:12 -0700 (Thu, 13 Aug 2009)
New Revision: 17814

Added:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Sphere.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/internal/DefaultVisualStyleBuilder.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Cube.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/CyQuad.java
   
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/Rectangle.java
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Text.java
Log:


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-08-13 23:05:53 UTC (rev 17813)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/CyDrawable.java
   2009-08-14 00:01:12 UTC (rev 17814)
@@ -46,5 +46,7 @@
         * @return set of compatible data types.
         */
        public Set<Class<?>> getCompatibleModels();
+       
+       public void setDetailFlag(boolean flag);
 
 }

Modified: 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/DefaultVisualStyleBuilder.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/DefaultVisualStyleBuilder.java
   2009-08-13 23:05:53 UTC (rev 17813)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/DefaultVisualStyleBuilder.java
   2009-08-14 00:01:12 UTC (rev 17814)
@@ -7,6 +7,7 @@
 
 import java.awt.Color;
 
+import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.vizmap.VisualMappingManager;
 import org.cytoscape.view.vizmap.VisualStyle;
 import org.cytoscape.view.vizmap.mappings.DiscreteMapping;
@@ -22,6 +23,8 @@
 
        // TODO: this attr name should be managed in model!!!
        private static final String NAME = "name";
+       private static final String INTERACTION = "interaction";
+       
 
        private static final String STYLE_TITLE = "Processing Default Style";
 
@@ -30,8 +33,11 @@
 
        private static final Color DEF_EDGE_COLOR = new Color(0, 30, 250);
        private static final double DEF_EDGE_OPACITY = 150d;
+       
+       private static final Color PP_COLOR = new Color(200, 20, 20);
+       private static final Color PD_COLOR = new Color(100, 200, 100);
 
-       private static final Color DEF_BACKGROUND_COLOR = new Color(200, 200, 
200);
+       private static final Color DEF_BACKGROUND_COLOR = Color.white;
 
        private VisualStyle style;
 
@@ -54,13 +60,20 @@
                final DiscreteMapping<String, Double> location = new 
DiscreteMapping<String, Double>(
                                NAME, String.class, NODE_Z_LOCATION);
                
-               randSize.putMapValue("YMR043W", 100d);
+               final DiscreteMapping<String, Color> interaction = new 
DiscreteMapping<String, Color>(
+                               INTERACTION, String.class, 
(VisualProperty<Color>) EDGE_COLOR);
+               
+               randSize.putMapValue("YMR043W", 60d);
                location.putMapValue("YMR043W", 500d);
+               
+               interaction.putMapValue("pp", PP_COLOR);
+               interaction.putMapValue("pd", PD_COLOR);
 
 
                style.addVisualMappingFunction(labelMapping);
                style.addVisualMappingFunction(randSize);
                style.addVisualMappingFunction(location);
+               style.addVisualMappingFunction(interaction);
                
                
                style.setDefaultValue(NODE_COLOR, DEF_NODE_COLOR);
@@ -68,6 +81,7 @@
 
                style.setDefaultValue(EDGE_COLOR, DEF_EDGE_COLOR);
                style.setDefaultValue(EDGE_OPACITY, DEF_EDGE_OPACITY);
+               style.setDefaultValue(EDGE_WIDTH, 3d);
 
                style.setDefaultValue(NETWORK_BACKGROUND_COLOR, 
DEF_BACKGROUND_COLOR);
 

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-13 23:05:53 UTC (rev 17813)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
   2009-08-14 00:01:12 UTC (rev 17814)
@@ -182,6 +182,7 @@
        
        private int numP;
 
+       float rotXDelta = 0;
        public void draw() {
                background(bgColor.getRed(), bgColor.getGreen(), 
bgColor.getGreen());
                lights();
@@ -191,9 +192,11 @@
                                / 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);
+               translate(width / 2+ translateX, height / 2+ translateY, height 
/ 2);
                rotateX(rotY);
                rotateY(rotX);
+               rotateZ(rotXDelta);
+               
                translate(-width / 2 + translateX, -height / 2 + translateY,
                                -height / 2);
 
@@ -204,10 +207,7 @@
                for (CyDrawable edge : edges)
                        edge.draw();
 
-               // particleManager.draw(gl);
-
-               
-               
+               // Reser camera and draw overlay
                camera();
                beginGL();
                gl.glClear(javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT);
@@ -216,6 +216,8 @@
                // 2D OpenGL UI
                if(isOverlay)
                        overlay.draw();
+               
+               rotXDelta += 0.002f;
        }
 
        public void beginGL() {
@@ -270,6 +272,11 @@
                  } else
                          loop();
                  
+         } else if( key == 'd') {
+                 // freeze
+                 for (CyDrawable node : nodes)
+                               node.setDetailFlag(false);
+                 
          }
            
        }

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-08-13 23:05:53 UTC (rev 17813)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Cube.java
  2009-08-14 00:01:12 UTC (rev 17814)
@@ -55,7 +55,9 @@
        
        private final List<CyDrawable> children;
        
+       private boolean detail = true;
        
+       
        private Map<VisualProperty<?>, Object> fieldMap;
        
        public Cube(PApplet parent, VisualLexicon lexicon) {
@@ -90,11 +92,18 @@
                p.noStroke();
                p.translate(x, y, z);
                p.fill(r, g, b, alpha);
+               //p.noFill();
+               //p.strokeWeight(1);
+               //p.sphereDetail(3);
+               //p.stroke(50, 100, 100, 50);
+               //p.sphere(size);
                p.box(size);
                p.popMatrix();
                
-               for(CyDrawable child: children)
-                       child.draw();
+//             if(detail) {
+                       for(CyDrawable child: children)
+                               child.draw();
+               
        }
 
        public List<CyDrawable> getChildren() {
@@ -109,8 +118,6 @@
                this.y = 
viewModel.getVisualProperty(NODE_Y_LOCATION).floatValue();             
                this.z = 
viewModel.getVisualProperty(NODE_Z_LOCATION).floatValue();
                
-               System.out.println("Z location = " + this.z);
-               
                this.size = 
viewModel.getVisualProperty(NODE_X_SIZE).floatValue();
                if(size <= 0)
                        size = DEF_SIZE;
@@ -130,13 +137,6 @@
                        this.alpha = 100;
                }
                
-//             String text = viewModel.getVisualProperty(NODE_LABEL);
-//             if(text != null || text.length() != 0) {
-//                     children.add(new Text(p, lexicon));
-//             }
-               
-               
-               
                // Set values for children
                for(CyDrawable child: children)
                        child.setContext(viewModel);
@@ -177,6 +177,11 @@
                this.children.add(child);
        }
 
+       public void setDetailFlag(boolean flag) {
+               // 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/CyQuad.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/CyQuad.java
        2009-08-13 23:05:53 UTC (rev 17813)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/CyQuad.java
        2009-08-14 00:01:12 UTC (rev 17814)
@@ -58,4 +58,9 @@
                
        }
 
+       public void setDetailFlag(boolean flag) {
+               // 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/Line.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Line.java
  2009-08-13 23:05:53 UTC (rev 17813)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Line.java
  2009-08-14 00:01:12 UTC (rev 17814)
@@ -22,8 +22,10 @@
        private Vec3D source;
        private Vec3D target;
        
-       private int r, g, b, alpha;
+       private float r, g, b, alpha;
        
+       private float strokeWidth = 1f;
+       
        public Line(PApplet p) {
                this.p = p;
                this.source = new Vec3D();
@@ -32,11 +34,12 @@
 
        public void draw() {
                if(source.z != target.z){
+                       
                        p.stroke(200, 0, 0, 70);
-                       p.strokeWeight(1);
+                       p.strokeWeight(strokeWidth);
                } else {
                        p.stroke(r, g, b, alpha);
-                       p.strokeWeight(2);
+                       p.strokeWeight(strokeWidth);
                }
                p.line(source.x, source.y, source.z, target.x, target.y, 
target.z);             
        }
@@ -53,13 +56,12 @@
 
        public void setContext(View<?> viewModel) {
                Paint edgePaint = viewModel.getVisualProperty(EDGE_COLOR);
-               
+               alpha = viewModel.getVisualProperty(EDGE_OPACITY).floatValue();
+               strokeWidth = 
viewModel.getVisualProperty(EDGE_WIDTH).floatValue();
                if(edgePaint instanceof Color) {
                        this.r = ((Color)edgePaint).getRed();
                        this.g = ((Color)edgePaint).getGreen();
                        this.b = ((Color)edgePaint).getBlue();
-                       //this.alpha = ((Color)edgePaint).getAlpha();
-                       this.alpha = 100;
                }
        }
 
@@ -85,4 +87,9 @@
                
        }
 
+       public void setDetailFlag(boolean flag) {
+               // 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/Rectangle.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Rectangle.java
     2009-08-13 23:05:53 UTC (rev 17813)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Rectangle.java
     2009-08-14 00:01:12 UTC (rev 17814)
@@ -145,4 +145,9 @@
                
        }
 
+       public void setDetailFlag(boolean flag) {
+               // 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/Sphere.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Sphere.java
                                (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Sphere.java
        2009-08-14 00:01:12 UTC (rev 17814)
@@ -0,0 +1,181 @@
+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_COLOR;
+import static 
org.cytoscape.view.presentation.property.TwoDVisualLexicon.NODE_OPACITY;
+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.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+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.model.VisualProperty;
+import org.cytoscape.view.presentation.processing.CyDrawable;
+
+import processing.core.PApplet;
+import toxi.geom.Vec3D;
+
+public class Sphere extends Vec3D implements CyDrawable {
+       
+       private static final long serialVersionUID = -3971892445041605908L;
+       private static final String DISPLAY_NAME = "Cube";
+       
+       private static final int DEF_SIZE = 20;
+       
+       private static final int OFFSET = 10;
+
+       
+       private boolean picked;
+       private Set<Class<?>> compatibleDataType;
+       
+       private final VisualLexicon lexicon;
+       
+       private PApplet p;
+       
+       private float size;
+       private int r, g, b, alpha;
+       
+       private final List<CyDrawable> children;
+       
+       
+       private Map<VisualProperty<?>, Object> fieldMap;
+       
+       public Sphere(PApplet parent, VisualLexicon lexicon) {
+               super();
+               this.p = parent;
+               this.lexicon = lexicon;
+               this.picked = false;
+               
+               this.children = new ArrayList<CyDrawable>();
+               // Create children for label
+               this.children.add(new Text(p, lexicon));
+               
+               compatibleDataType = new HashSet<Class<?>>();
+               compatibleDataType.add(CyNode.class);
+       }
+
+       public Set<Class<?>> getCompatibleModels() {
+               return compatibleDataType;
+       }
+
+       public String getDisplayName() {
+               return DISPLAY_NAME;
+       }
+
+       public Icon getIcon(int width, int height) {
+               // TODO Implement icon renderer
+               return null;
+       }
+
+       public void draw() {
+               p.pushMatrix();
+               p.noStroke();
+               p.translate(x, y, z);
+               p.fill(r, g, b, alpha);
+               
+               p.box(size);
+               p.popMatrix();
+               
+               for(CyDrawable child: children)
+                       child.draw();
+       }
+
+       public List<CyDrawable> getChildren() {
+               // TODO Auto-generated method stub
+               return children;
+       }
+
+       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();
+               
+               System.out.println("Z location = " + this.z);
+               
+               this.size = 
viewModel.getVisualProperty(NODE_X_SIZE).floatValue();
+               if(size <= 0)
+                       size = DEF_SIZE;
+               
+               Paint color = viewModel.getVisualProperty(NODE_COLOR);
+               Double opacity = viewModel.getVisualProperty(NODE_OPACITY);
+               if(picked) {
+                       this.r = 0;
+                       g = 250;
+                       b = 0;
+                       alpha = 255;
+               }else if(color instanceof Color) {
+                       this.r = ((Color)color).getRed();
+                       this.g = ((Color)color).getGreen();
+                       this.b = ((Color)color).getBlue();
+                       //this.alpha = opacity.intValue();              
+                       this.alpha = 100;
+               }
+               
+//             String text = viewModel.getVisualProperty(NODE_LABEL);
+//             if(text != null || text.length() != 0) {
+//                     children.add(new Text(p, lexicon));
+//             }
+               
+               
+               
+               // Set values for children
+               for(CyDrawable child: children)
+                       child.setContext(viewModel);
+       }
+       
+       public void setContext(View<?> viewModel, VisualProperty<?> vp) {
+               // If the VP is not in the context, ignore
+               if(lexicon.getAllVisualProperties().contains(vp) == false) 
return;
+               
+               // Extract value for the visual property
+               Object value = viewModel.getVisualProperty(vp);
+               
+       }
+
+       public boolean isPicked() {
+               return picked;
+       }
+
+       public void pick(float cx, float cy) {
+               
+               final float distance = PApplet.dist(cx, cy, p.screenX(this.x, 
this.y, this.z), p.screenY(x, y, z));
+               System.out.println("Distance = " + distance);
+               if(distance < 200){
+                       picked = true;
+                       System.out.println("PICKED!!");
+                       this.r = 0;
+                       g = 250;
+                       b = 0;
+                       alpha = 255;
+                       System.out.println("Color of PICKED node" + g); 
+               } else
+                       picked = false;
+               
+       }
+
+       public void addChild(CyDrawable child) {
+               // TODO Auto-generated method stub
+               this.children.add(child);
+       }
+
+       public void setDetailFlag(boolean flag) {
+               // 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/Text.java
===================================================================
--- 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Text.java
  2009-08-13 23:05:53 UTC (rev 17813)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Text.java
  2009-08-14 00:01:12 UTC (rev 17814)
@@ -81,18 +81,14 @@
 //             PGraphicsOpenGL graphics = (PGraphicsOpenGL) p.g;
 //             PMatrix3D m_inv = graphics.camera;
 //
-//             p.pushMatrix();
 //             p.applyMatrix(
 //                             1, 0, 0, m_inv.m03, 
 //                             0, 1, 0, m_inv.m13, 
 //                             0, 0, 1, m_inv.m23, 
 //                             m_inv.m30, m_inv.m31, m_inv.m32, m_inv.m33);
 //
-
                p.fill(r, g, b, alpha);
-               p.text(text, x,y, z);
-
-//             p.popMatrix();
+               p.text(text, x, y, z+30);
        }
 
        public List<CyDrawable> getChildren() {
@@ -104,8 +100,6 @@
 
                this.text = viewModel.getVisualProperty(NODE_LABEL);
 
-               System.out.println("********************** Node Text = " + 
text);
-
                this.x = 
viewModel.getVisualProperty(NODE_X_LOCATION).floatValue()
                                + offsetX;
                this.y = 
viewModel.getVisualProperty(NODE_Y_LOCATION).floatValue()
@@ -161,4 +155,9 @@
 
        }
 
+       public void setDetailFlag(boolean flag) {
+               // 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