Save This Page
Home » jakarta-jmeter-2.3.4_src » org.apache.jorphan.gui » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *   http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    *
   17    */
   18   
   19   package org.apache.jorphan.gui;
   20   
   21   /**
   22    * Renders a rate in a JTable.
   23    *
   24    * The output is in units appropriate to its dimension:
   25    * <p>
   26    * The number is represented in one of:
   27    * - requests/second
   28    * - requests/minute
   29    * - requests/hour.
   30    * <p>
   31    * Examples: "34.2/sec" "0.1/sec" "43.0/hour" "15.9/min"
   32    */
   33   public class RateRenderer extends NumberRenderer{
   34   
   35       public RateRenderer(String format) {
   36           super(format);
   37       }
   38   
   39       public void setValue(Object value) {
   40           if (value == null || ! (value instanceof Double)) {
   41               setText("#N/A"); // TODO: should this just call super()?
   42               return;
   43           }
   44           double rate = ((Double) value).doubleValue();
   45           if (rate == Double.MAX_VALUE){
   46               setText("#N/A"); // TODO: should this just call super()?
   47               return;
   48           }
   49   
   50           String unit = "sec";
   51   
   52           if (rate < 1.0) {
   53               rate *= 60.0;
   54               unit = "min";
   55           }
   56           if (rate < 1.0) {
   57               rate *= 60.0;
   58               unit = "hour";
   59           }
   60           setText(formatter.format(rate) + "/" + unit);
   61       }
   62   }

Save This Page
Home » jakarta-jmeter-2.3.4_src » org.apache.jorphan.gui » [javadoc | source]