Author: k
Date: 2009-08-08 03:27:55 -0700 (Sat, 08 Aug 2009)
New Revision: 17750
Added:
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ui/Overlay.java
Modified:
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/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/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
Log:
Overlay drawing code had been moved to a new class.
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-08 08:39:33 UTC (rev 17749)
+++
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingNetworkRenderer.java
2009-08-08 10:27:55 UTC (rev 17750)
@@ -25,6 +25,7 @@
import org.cytoscape.view.presentation.processing.CyDrawable;
import org.cytoscape.view.presentation.processing.Pickable;
import
org.cytoscape.view.presentation.processing.internal.particle.ParticleManager;
+import org.cytoscape.view.presentation.processing.internal.ui.Overlay;
import processing.core.PApplet;
import processing.core.PFont;
@@ -45,8 +46,6 @@
// Mode of renderer. For now, it is set to non-OpenGL version.
private static final String MODE = P3D;
private static final int FRAME_RATE = 30;
-
- private float fontSize = 32;
private Dimension windowSize;
private CyNetworkView view;
@@ -61,10 +60,15 @@
private GLCanvas canvas;
+ private Overlay overlay;
+
private ParticleManager particleManager;
private VerletPhysics physics;
private float rotX, rotY, zoom = 200;
private AABB boundingBox;
+
+ // Control
+ private boolean isOverlay = false;
/**
* Constructor. Create a PApplet component based on the size given as
@@ -126,7 +130,7 @@
PGraphicsOpenGL pgl;
GL gl;
- PFont defFont;
+
class GLRenderer implements GLEventListener {
GL gl;
@@ -156,14 +160,11 @@
System.out.println("%%%%%%%%%%%%% Setup called for P5");
/* setup p5 */
size(windowSize.width, windowSize.width, OPENGL);
- //hint(ENABLE_OPENGL_4X_SMOOTH);
- //hint(ENABLE_NATIVE_FONTS);
+ // hint(ENABLE_OPENGL_4X_SMOOTH);
+ // hint(ENABLE_NATIVE_FONTS);
noStroke();
frameRate(FRAME_RATE);
- defFont = createFont("SansSerif", fontSize);
- textFont(defFont);
-
// Particle simulator
physics = new VerletPhysics();
physics.friction = 1000;
@@ -185,6 +186,8 @@
numP = nodes.length;
particleManager = new ParticleManager(numP, this, physics);
+ overlay = new Overlay(this,
view.getSource().attrs().get("name", String.class));
+
System.out.println("%%%%%%%%%%%%% Setup DONE for P5");
}
@@ -208,42 +211,25 @@
rotateY(rotX);
translate(-width / 2 + translateX, -height / 2 + translateY,
-height / 2);
-
+
for (CyDrawable node : nodes)
node.draw();
for (CyDrawable edge : edges)
edge.draw();
- //particleManager.draw(gl);
+ // particleManager.draw(gl);
camera();
beginGL();
gl.glClear(javax.media.opengl.GL.GL_DEPTH_BUFFER_BIT);
- ((PGraphicsOpenGL)g).endGL();
-
+ ((PGraphicsOpenGL) g).endGL();
+
// 2D OpenGL UI
- drawOverlay();
+ if(isOverlay)
+ overlay.draw();
}
- private void drawOverlay() {
- fill(255, 255, 255, 90);
- noStroke();
- rect(10, height - 100, width-20, 90);
- fill(255, 255, 255, 230);
- text("Processing Renderer", 30, height-90+fontSize);
-
- fill(255, 255, 255, 90);
- stroke(100, 100, 100, 200);
- rect(10, 10, width-20, 30);
- noStroke();
- fill(255, 0, 0, 90);
- rect(11, 11, width/3, 29);
-
- }
-
-
-
public void beginGL() {
pgl = (PGraphicsOpenGL) g;
gl = pgl.beginGL();
@@ -271,14 +257,22 @@
if (mouseButton != CENTER)
return;
-// System.out.println("===Mouse Click");
-// for (int i = 0; i < nodes.length; i++) {
-// if (nodes[i] instanceof Pickable) {
-// ((Pickable) nodes[i]).pick(mouseX, mouseY);
-// }
-// }
+ // System.out.println("===Mouse Click");
+ // for (int i = 0; i < nodes.length; i++) {
+ // if (nodes[i] instanceof Pickable) {
+ // ((Pickable) nodes[i]).pick(mouseX, mouseY);
+ // }
+ // }
}
+ @Override
+ public void keyPressed(){
+ // if the key is between 'A'(65) and 'z'(122)
+ if( key == 'o')
+ isOverlay = !isOverlay;
+
+ }
+
public Icon getDefaultIcon(VisualProperty<?> vp) {
// 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/ProcessingPresentationFactory.java
===================================================================
---
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingPresentationFactory.java
2009-08-08 08:39:33 UTC (rev 17749)
+++
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ProcessingPresentationFactory.java
2009-08-08 10:27:55 UTC (rev 17750)
@@ -21,7 +21,7 @@
NetworkViewChangedListener {
private static final Dimension DEFAULT_WINDOW_SIZE = new Dimension(1200,
- 1000);
+ 900);
// private final Map<Class<?>, Class<? extends P5Renderer<?>>>
rendererMap;
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-08 08:39:33 UTC (rev 17749)
+++
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Cube.java
2009-08-08 10:27:55 UTC (rev 17750)
@@ -1,7 +1,7 @@
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.ThreeDVisualLexicon.*;
+import static org.cytoscape.view.presentation.property.TwoDVisualLexicon.*;
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;
@@ -98,7 +98,7 @@
this.y =
viewModel.getVisualProperty(NODE_Y_LOCATION).floatValue();
if(p.random(1)> 0.5) {
- viewModel.setVisualProperty(NODE_Z_LOCATION, 500d);
+ viewModel.setVisualProperty(NODE_Z_LOCATION, 2000d);
}
this.z =
viewModel.getVisualProperty(NODE_Z_LOCATION).floatValue();
@@ -108,6 +108,7 @@
size = DEF_SIZE;
Paint color = viewModel.getVisualProperty(NODE_COLOR);
+ Double opacity = viewModel.getVisualProperty(NODE_OPACITY);
if(picked) {
this.r = 0;
g = 250;
@@ -117,7 +118,8 @@
this.r = ((Color)color).getRed();
this.g = ((Color)color).getGreen();
this.b = ((Color)color).getBlue();
- this.alpha = ((Color)color).getAlpha();
+ //this.alpha = opacity.intValue();
+ this.alpha = 100;
}
}
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-08 08:39:33 UTC (rev 17749)
+++
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/CyQuad.java
2009-08-08 10:27:55 UTC (rev 17750)
@@ -4,6 +4,7 @@
import java.util.Set;
import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.VisualProperty;
import org.cytoscape.view.presentation.processing.CyDrawable;
import org.cytoscape.view.presentation.processing.Pickable;
@@ -47,4 +48,9 @@
}
+ public void setContext(View<?> viewModel, VisualProperty<?> vp) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified:
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/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-08 08:39:33 UTC (rev 17749)
+++
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Line.java
2009-08-08 10:27:55 UTC (rev 17750)
@@ -7,6 +7,7 @@
import java.util.Set;
import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.VisualProperty;
import org.cytoscape.view.presentation.processing.CyDrawable;
import org.cytoscape.view.presentation.processing.EdgeItem;
@@ -30,7 +31,13 @@
}
public void draw() {
- p.stroke(r, g, b, alpha);
+ if(source.z != target.z){
+ p.stroke(200, 0, 0, 70);
+ p.strokeWeight(1);
+ } else {
+ p.stroke(r, g, b, alpha);
+ p.strokeWeight(2);
+ }
p.line(source.x, source.y, source.z, target.x, target.y,
target.z);
}
@@ -51,9 +58,8 @@
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);
+ //this.alpha = ((Color)edgePaint).getAlpha();
+ this.alpha = 100;
}
}
@@ -69,4 +75,9 @@
target.z =
targetView.getVisualProperty(NODE_Z_LOCATION).floatValue();
}
+ public void setContext(View<?> viewModel, VisualProperty<?> vp) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified:
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/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-08 08:39:33 UTC (rev 17749)
+++
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/shape/Rectangle.java
2009-08-08 10:27:55 UTC (rev 17750)
@@ -19,6 +19,7 @@
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;
@@ -134,4 +135,9 @@
picked = false;
}
+ public void setContext(View<?> viewModel, VisualProperty<?> vp) {
+ // TODO Auto-generated method stub
+
+ }
+
}
Added:
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ui/Overlay.java
===================================================================
---
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ui/Overlay.java
(rev 0)
+++
csplugins/trunk/soc/kozo/processing-renderer/processing-rendering-engine/src/main/java/org/cytoscape/view/presentation/processing/internal/ui/Overlay.java
2009-08-08 10:27:55 UTC (rev 17750)
@@ -0,0 +1,57 @@
+package org.cytoscape.view.presentation.processing.internal.ui;
+
+import processing.core.PApplet;
+import processing.core.PFont;
+
+public class Overlay {
+
+ // Pre-defined font sizes
+ private final float smallSize = 12;
+ private float fontSize = 32;
+
+ // reference to parent
+ private PApplet p;
+
+ private PFont bigFont;
+ private PFont smallFont;
+
+ private String title;
+
+ public Overlay(PApplet p, String title) {
+ this.p = p;
+ this.title = title;
+
+ bigFont = this.p.createFont("SansSerif", fontSize);
+ smallFont = this.p.createFont("SansSerif", smallSize);
+
+ }
+
+ public void draw() {
+
+ p.fill(255, 255, 255, 90);
+ p.noStroke();
+ p.rect(10, p.height - 100, p.width-20, 90);
+// p.rect(p.width-420, 60, 400, p.height-200);
+// p.fill(50, 50, 50, 120);
+// p.rect(p.width-420, 60, 400, 80);
+
+ p.fill(255, 255, 255, 230);
+ p.textFont(bigFont);
+ p.text("Network: " + title, 30, p.height-90+fontSize);
+ p.textFont(smallFont);
+ p.text((int)p.frameRate + " FPS", p.width-100,
p.height-50+fontSize);
+
+ p.fill(255, 255, 255, 90);
+ p.stroke(100, 100, 100, 200);
+ p.rect(10, 10, p.width-20, 30);
+ p.noStroke();
+ p.fill(255, 0, 0, 90);
+ p.rect(11, 11, p.width/3, 29);
+
+ }
+
+ private void drawWindow() {
+
+ }
+
+}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---