commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nico...@apache.org
Subject svn commit: r646846 - /commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/FlotRenderer.java
Date Thu, 10 Apr 2008 15:34:19 GMT
Author: nicolas
Date: Thu Apr 10 08:34:13 2008
New Revision: 646846

URL: http://svn.apache.org/viewvc?rev=646846&view=rev
Log:
fix test

Modified:
    commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/FlotRenderer.java

Modified: commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/FlotRenderer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/FlotRenderer.java?rev=646846&r1=646845&r2=646846&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/FlotRenderer.java
(original)
+++ commons/sandbox/monitoring/trunk/src/main/java/org/apache/commons/monitoring/reporting/FlotRenderer.java
Thu Apr 10 08:34:13 2008
@@ -41,10 +41,8 @@
  * </pre>
  *
  * </li>
- * <li>
- * a &lt;div& id="placeholder"gt; to draw the graph into, having <tt>width</tt>
and <tt>height</tt>
- * style set.
- * </li>
+ * <li> a &lt;div& id="placeholder"gt; to draw the graph into, having
+ * <tt>width</tt> and <tt>height</tt> style set. </li>
  * </ul>
  *
  * @see http://code.google.com/p/flot/
@@ -68,7 +66,7 @@
      * org.apache.commons.monitoring.reporting.Renderer.Options)
      */
     @Override
-    public void render( Context ctx, Collection<Monitor> monitors, Options options
)
+    public void render( final Context ctx, Collection<Monitor> monitors, Options options
)
     {
         prepareRendering( ctx, monitors, options );
         ctx.print( "$.plot($('#placeholder'), [" );
@@ -96,7 +94,8 @@
                 ctx.print( "\", data: " );
                 ctx.print( "[" );
                 int x = 0;
-                for ( Iterator<Monitor> iterator = monitors.iterator(); iterator.hasNext();
)
+                int rendered = 0;
+                for ( final Iterator<Monitor> iterator = monitors.iterator(); iterator.hasNext();
)
                 {
                     Monitor monitor = iterator.next();
                     x++;
@@ -106,17 +105,27 @@
                         continue;
                     }
                     ctx.put( "x", x );
+                    if ( rendered > 0 )
+                    {
+                        ctx.print( "," );
+                    }
+                    ctx.put( "rendered", false );
                     render( ctx, value, new OptionsSupport()
                     {
                         @Override
                         public boolean render( String role, String string )
                         {
-                            return string.equals( attribute );
+                            boolean render = string.equals( attribute );
+                            if ( render )
+                            {
+                                ctx.put( "rendered", true );
+                            }
+                            return render;
                         }
-                    });
-                    if ( iterator.hasNext() )
+                    } );
+                    if ( ( (Boolean) ctx.get( "rendered" ) ).booleanValue() )
                     {
-                        ctx.print( "," );
+                        rendered++;
                     }
                 }
                 ctx.print( "]" );
@@ -151,7 +160,9 @@
 
     /**
      * {@inheritDoc}
-     * @see org.apache.commons.monitoring.reporting.AbstractRenderer#render(org.apache.commons.monitoring.reporting.Context,
org.apache.commons.monitoring.Monitor.Key)
+     *
+     * @see org.apache.commons.monitoring.reporting.AbstractRenderer#render(org.apache.commons.monitoring.reporting.Context,
+     * org.apache.commons.monitoring.Monitor.Key)
      */
     @Override
     protected void render( Context ctx, Key key )
@@ -161,7 +172,10 @@
 
     /**
      * {@inheritDoc}
-     * @see org.apache.commons.monitoring.reporting.AbstractRenderer#renderDetached(org.apache.commons.monitoring.reporting.Context,
org.apache.commons.monitoring.listeners.Detachable, org.apache.commons.monitoring.reporting.Renderer.Options)
+     *
+     * @see org.apache.commons.monitoring.reporting.AbstractRenderer#renderDetached(org.apache.commons.monitoring.reporting.Context,
+     * org.apache.commons.monitoring.listeners.Detachable,
+     * org.apache.commons.monitoring.reporting.Renderer.Options)
      */
     @Override
     protected void renderDetached( Context ctx, Detachable detached, Options options )



Mime
View raw message