Author: kono
Date: 2009-08-11 17:56:16 -0700 (Tue, 11 Aug 2009)
New Revision: 17780

Added:
   
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Text.java
Log:
Text drawing methods had been added.

Added: 
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
                          (rev 0)
+++ 
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Text.java
  2009-08-12 00:56:16 UTC (rev 17780)
@@ -0,0 +1,148 @@
+package org.cytoscape.view.presentation.processing.internal.shape;
+
+import static org.cytoscape.view.presentation.property.ThreeDVisualLexicon.*;
+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.Map;
+import java.util.Set;
+
+import javax.swing.Icon;
+
+import org.cytoscape.model.CyEdge;
+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.Pickable;
+
+import processing.core.PApplet;
+import processing.core.PFont;
+import toxi.geom.Vec3D;
+
+public class Text extends Vec3D implements CyDrawable, Pickable {
+
+       
+       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 String text;
+       
+       private float offsetX = 30;
+       private float offsetY = 0;
+       private float offsetZ = 0;
+       
+       private PFont font;
+       
+       
+       private Map<VisualProperty<?>, Object> fieldMap;
+       
+       public Text(PApplet parent, VisualLexicon lexicon) {
+               super();
+               this.p = parent;
+               this.lexicon = lexicon;
+               this.picked = false;
+               
+               
+               compatibleDataType = new HashSet<Class<?>>();
+               compatibleDataType.add(CyNode.class);
+               compatibleDataType.add(CyEdge.class);
+       }
+
+       public Set<Class<?>> getCompatibleModels() {
+               return compatibleDataType;
+       }
+
+
+       public Icon getIcon(int width, int height) {
+               // TODO Implement icon renderer
+               return null;
+       }
+
+       public void draw() {
+               
+               p.fill(r, g, b, alpha);
+               p.text(text, x, y, z);
+       }
+
+       public List<CyDrawable> getChildren() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       public void setContext(View<?> viewModel) {
+               
+               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() + offsetY;
+               this.z = 
viewModel.getVisualProperty(NODE_Z_LOCATION).floatValue() + offsetZ;
+               
+               Paint color = viewModel.getVisualProperty(NODE_LABEL_COLOR);
+               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;
+               }       
+       }
+       
+       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
+               
+       }
+
+       
+
+}


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