Author: paperwing
Date: 2012-02-08 16:05:42 -0800 (Wed, 08 Feb 2012)
New Revision: 28217

Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
Log:
refs #654 added support for the nodel label color visual property

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
      2012-02-08 23:29:58 UTC (rev 28216)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodeLabelsProcedure.java
      2012-02-09 00:05:42 UTC (rev 28217)
@@ -29,6 +29,8 @@
        private static final float TEXT_CHARACTER_WIDTH = 0.612f;
        private static final int TEXT_FONT_SIZE = 9;
        
+       private static final Color TEXT_DEFAULT_COLOR = Color.BLACK;
+       
        private TextRenderer textRenderer;
        private Font defaultFont = new Font("SansSerif", Font.PLAIN, 
TEXT_FONT_SIZE);
        
@@ -40,7 +42,7 @@
                GL2 gl = graphicsData.getGlContext();
                
                // Increase rendering efficiency; can set to true if desired
-//             textRenderer.setSmoothing(false);
+               textRenderer.setSmoothing(false);
        }
 
        @Override
@@ -63,9 +65,8 @@
         gl.glGetIntegerv(GL2.GL_VIEWPORT, viewPort, 0);
                
                String text;
+               Color textColor;
                
-               textRenderer.setColor(Color.BLACK);
-               
                gl.glPushMatrix();
                textRenderer.beginRendering(graphicsData.getScreenWidth(), 
graphicsData.getScreenHeight(), true);
                
@@ -80,29 +81,12 @@
                        // Draw it only if the visual property says it is 
visible
                        if 
(nodeView.getVisualProperty(MinimalVisualLexicon.NODE_VISIBLE)) {
                                
-//                             gl.glTranslatef(x, y, z);
-                               
                                gl.glColor3f(0.2f, 0.2f, 0.2f);
                                
                                text = 
nodeView.getVisualProperty(MinimalVisualLexicon.NODE_LABEL);
                                
-//                             gl.glTranslatef((float) TEXT_OFFSET.x(),
-//                                             (float) TEXT_OFFSET.y(),
-//                                             (float) TEXT_OFFSET.z());
-                               
                                if (text != null) {
                                        
-//                                     gl.glScalef(TEXT_SCALE, TEXT_SCALE, 
TEXT_SCALE);
-                                       // textRenderer.drawCenteredText(gl, 
text, TEXT_OFFSET);
-                                       // textRenderer.drawCenteredText(gl, 
"aac");
-                                       
-//                                     text = "test" + nodeView.getSUID();
-//                                     textRenderer.draw3D(text, 
-//                                                     x + (float) 
TEXT_OFFSET.x(), 
-//                                                     y + (float) 
TEXT_OFFSET.y(), 
-//                                                     z + (float) 
TEXT_OFFSET.z(), 
-//                                                     TEXT_SCALE);
-                                       
                                        Vector3 text3dPosition = new Vector3(x, 
y, z);
                                        Vector3 screenCoordinates = 
RenderToolkit.convert3dToScreen(gl, text3dPosition, modelView, projection, 
viewPort);
 //                                     System.out.println("Node label " + (new 
Vector3(x, y, z)) + " mapped to: " + screenCoordinates);
@@ -112,10 +96,18 @@
                                        // Only draw the text if the front side 
of the camera faces it
                                        if (offsetFromCamera.magnitudeSquared() 
> Double.MIN_NORMAL 
                                                        && 
graphicsData.getCamera().getDirection().angle(offsetFromCamera) <= Math.PI / 2) 
{
+                                               
+                                               // TODO: Check if there is a 
way around this cast
+                                               textColor = (Color) 
nodeView.getVisualProperty(MinimalVisualLexicon.NODE_LABEL_COLOR);
+                                               if (textColor == null) {
+                                                       
+                                                       // Use black as default 
if no node label color was found
+                                                       textColor = 
TEXT_DEFAULT_COLOR;
+                                               }
+                                               
+                                               
textRenderer.setColor(textColor);
                                                textRenderer.draw(text, (int) 
screenCoordinates.x() - findTextScreenWidth(text) / 2, (int) 
screenCoordinates.y());              
                                        }
-                                       
-//                                     textRenderer.draw(text, 300, 300);
                                }
                        }
                }

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