Example usage for java.lang Math ceil

List of usage examples for java.lang Math ceil

Introduction

In this page you can find the example usage for java.lang Math ceil.

Prototype

public static double ceil(double a) 

Source Link

Document

Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

Usage

From source file:no.met.jtimeseries.marinogram.MarinogramWindPlot.java

private XYPlot createPlot(TimeZone timezone, boolean plotWindDirection, boolean plotWindSpeed) {
    ChartPlotter plotter = new ChartPlotter();
    // default setting
    plotter.setHeight(this.getHeight());
    plotter.setWidth(this.getWidth());
    plotter.setPlotDefaultProperties("", "");
    Color windSpeedColor = new Color(0, 0, 0);
    Color windDirectionColor = new Color(0, 0, 0);
    // plot style
    PlotStyle.Builder currentStyleBuilder = new PlotStyle.Builder("Wind");
    PlotStyle plotStyle;//from  w  w w . jav  a 2 s.  c o  m
    NumberPhenomenon windDirection = getLocationForecastDataModel()
            .getPhenomenen(PhenomenonName.WindDirectionDegree.toString(), NumberPhenomenon.class);
    NumberPhenomenon windSpeed = getLocationForecastDataModel()
            .getPhenomenen(PhenomenonName.WindSpeedMPS.toString(), NumberPhenomenon.class);
    if (windSpeed == null || windDirection == null) {
        return null;
    }

    double tick = (windSpeed.getMaxValue() - windSpeed.getMinValue()) / 3;
    tick = Math.ceil(tick);
    double lowBound = Math.floor(windSpeed.getMinValue() / (tick)) * (tick);
    //The minimum scale is 0
    lowBound = lowBound < 0 ? 0 : lowBound;
    lowBound = lowBound - tick / 2;
    double upperBound = lowBound + tick * 6;

    // reference the range axis
    NumberAxis leftNumberAxis = new NumberAxis();
    leftNumberAxis.setLabel(messages.getString("parameter.wind") + " (m/s)");
    leftNumberAxis.setLabelPaint(windSpeedColor);
    leftNumberAxis.setTickLabelPaint(windSpeedColor);
    //int tickUnit = (int) Math.ceil((upperBound - lowBound) / 6);
    leftNumberAxis.setTickUnit(new NumberTickUnit(tick));
    leftNumberAxis.setLowerBound(lowBound);
    leftNumberAxis.setUpperBound(upperBound);

    NumberAxis rightNumberAxis = new NumberAxis();
    rightNumberAxis.setLabel(messages.getString("label.knots"));
    rightNumberAxis.setLabelPaint(windSpeedColor);
    rightNumberAxis.setTickLabelPaint(windSpeedColor);
    lowBound = lowBound / KNOT;
    upperBound = upperBound / KNOT;
    rightNumberAxis.setLowerBound(lowBound);
    rightNumberAxis.setUpperBound(upperBound);
    rightNumberAxis.setTickUnit(new NumberTickUnit(tick / KNOT));
    NumberFormat formatter = new DecimalFormat("#0.0");
    rightNumberAxis.setNumberFormatOverride(formatter);

    List<Date> shortTermTimeList = this.getShortTermTime(windDirection.getTime().get(0));

    // set thte plot current speed color to be transparent if show current
    // speed is false
    if (!plotWindSpeed) {
        windSpeedColor = new Color(0, 0, 0, 0);
    }

    // plot style
    plotStyle = currentStyleBuilder.spline(SplineStyle.HYBRID).stroke(new BasicStroke(2.0f))
            .seriesColor(windSpeedColor).numberAxis(leftNumberAxis).nonNegative(true).build();

    // Draw the current direction even if plotCurrentSpeed is false (but
    // with transparent in such a case)
    // for the purpose to keep the same background grid and tick label on
    // the y-axis
    // no matter the wave height is shown or not
    plotter.addLineChart(TimeBase.SECOND, windSpeed, plotStyle);

    plotter.getPlot().setRangeAxis(1, rightNumberAxis);
    plotter.getPlot().setOutlineVisible(true);

    Date minDate = shortTermTimeList.get(0);
    Date maxDate = shortTermTimeList.get(shortTermTimeList.size() - 1);
    plotter.setDomainRange(minDate, maxDate);
    plotter.setDomainDateFormat(timezone, "HH");
    // set domain range after (must) plot all the data
    plotter.addHourBasedDomainGridLines();
    // invisible domain axis
    plotter.getPlot().getDomainAxis().setTickLabelsVisible(false);
    // add markers
    plotter.addDomainMarkers(shortTermTimeList, timezone, locale);

    if (plotWindDirection) {
        List<Date> symbolTimes = Utility.filterMinimumHourInterval(windDirection.getTime(), 2, 1);
        InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes);
        windDirection.filter(symbolTimesFilter);
        windSpeed = null;
        if (plotWindSpeed) {
            windSpeed = getLocationForecastDataModel().getPhenomenen(PhenomenonName.WindSpeedMPS.toString(),
                    NumberPhenomenon.class);
            windSpeed.filter(symbolTimesFilter);
            windSpeed = windSpeed.scaling(1 / KNOT);
        }

        plotStyle = currentStyleBuilder.seriesColor(windDirectionColor).build();
        // when plot wind direction, the arrow should be rotated 180 degree
        windDirection = windDirection.transform(180);
        plotter.addArrowDirectionPlot(windDirection, windSpeed, 2, plotStyle);
        // transform back after plot
        windDirection = windDirection.transform(180);
    }
    plotter.getPlot().setRangeZeroBaselineVisible(false);

    return plotter.getPlot();

}

From source file:bb.mcmc.analysis.GewekeConvergeStat.java

@Override
protected double calculateEachStat(String key) {

    final double[] t = traceValues.get(key);

    final int length = t.length;
    final int indexStart = (int) Math.floor(length * (1 - frac2));
    final int indexEnd = (int) Math.ceil(length * frac1);
    final double[] dStart = Arrays.copyOfRange(t, 0, indexEnd);
    final double[] dEnd = Arrays.copyOfRange(t, indexStart, length);
    final double meanStart = DiscreteStatistics.mean(dStart);
    final double meanEnd = DiscreteStatistics.mean(dEnd);
    final double varStart = ConvergeStatUtils.spectrum0(dStart) / dStart.length;
    final double varEnd = ConvergeStatUtils.spectrum0(dEnd) / dEnd.length;
    final double bothVar = varStart + varEnd;

    double stat = (meanStart - meanEnd) / Math.sqrt(bothVar);

    if (Double.isNaN(stat)) { //Use two separate if to handle other NaN cases later
        if (Double.isNaN(bothVar)) {
            stat = Double.NEGATIVE_INFINITY;
            System.err.println(STATISTIC_NAME + " could not be calculated for variable with id " + key
                    + ". This is due to logged values being unchanged during the run");//. Check log file for details. ");
        }//www  . j  a v  a 2 s .  com
    }
    return stat;

}

From source file:com.opengamma.analytics.financial.model.option.pricing.fourier.FFTPricer.java

/**
 * Price a European option across a range of strikes using a FFT. The terminal price is assumed to be of the form S = F*exp(x), where F is the forward,
 * and x is a random variable with a known characteristic function.
 * @param forward The forward value of the underlying
 * @param discountFactor //from w w  w . ja v a2s  .co  m
 * @param t Time to expiry
 * @param isCall true for call 
 * @param ce The Characteristic Exponent (log of characteristic function) of the returns of the underlying
 * @param lowestStrike The lowest strike to return (the actual value will depend on the set up, but is guaranteed to be less than this) 
 * @param highestStrike The highest strike to return (the actual value will depend on the set up, but is guaranteed to be greater than this) 
 * @param minStrikesDisplayed minimum number of strikes returned (actual number depends on set up) 
 * @param limitSigma An estimate of the implied vol used to calculate limits in the numerical routines 
 * @param alpha Regularization factor. Values of 0 or -1 are not allowed. -0.5 is recommended  
 * @param tol Tolerance - smaller values give higher accuracy 
 * @return array of arrays of strikes and prices 
 */
public double[][] price(final double forward, final double discountFactor, final double t, final boolean isCall,
        final MartingaleCharacteristicExponent ce, final double lowestStrike, final double highestStrike,
        final int minStrikesDisplayed, final double limitSigma, final double alpha, final double tol) {

    Validate.notNull(ce, "characteristic exponent");
    Validate.isTrue(tol > 0.0, "need tol > 0");
    Validate.isTrue(alpha != 0.0 && alpha != -1.0, "alpha cannot be -1 or 0");
    Validate.isTrue(highestStrike >= lowestStrike, "need highestStrike >= lowestStrike");
    //   Validate.isTrue(lowestStrike <= forward, "need lowestStrike <= forward");
    //    Validate.isTrue(highestStrike >= forward, "need highestStrike >= forward");
    Validate.isTrue(limitSigma > 0.0, "need limitSigma > 0");

    double kMax;
    final double limitSigmaRootT = limitSigma * Math.sqrt(t);
    final double atm = NORMAL.getCDF(limitSigmaRootT / 2.0);

    if (alpha > 0) {
        kMax = -Math.log((2 * atm - 1) * tol) / alpha;
    } else if (alpha < -1.0) {
        kMax = Math.log((2 * atm - 1) * tol) / (1 + alpha);
    } else {
        kMax = -Math.log(2 * (1 - atm) * tol) * Math.max(-1.0 / alpha, 1 / (1 + alpha));
    }

    final EuropeanCallFourierTransform psi = new EuropeanCallFourierTransform(ce);
    final Function1D<ComplexNumber, ComplexNumber> psiFunction = psi.getFunction(t);
    final double xMax = LIMIT_CALCULATOR.solve(psiFunction, alpha, tol);

    double deltaK;
    if (highestStrike == lowestStrike) {
        deltaK = Math.PI / xMax;
    } else {
        deltaK = Math.min(Math.log(highestStrike / lowestStrike) / (minStrikesDisplayed - 1), Math.PI / xMax);
    }

    final double log2 = Math.log(2);
    final int twoPow = (int) Math.ceil(Math.log(kMax / deltaK) / log2);

    final int n = (int) Math.pow(2, twoPow);
    final double delta = 2 * Math.PI / n / deltaK;
    final int m = (int) (xMax * deltaK * n / 2 / Math.PI);

    final int nLowStrikes = (int) Math.max(0, Math.ceil(Math.log(forward / lowestStrike) / deltaK));
    final int nHighStrikes = (int) Math.max(0, Math.ceil(Math.log(highestStrike / forward) / deltaK));

    return price(forward, discountFactor, t, isCall, ce, nLowStrikes, nHighStrikes, alpha, delta, n, m);
}

From source file:org.onebusaway.nyc.vehicle_tracking.impl.inference.BlockStateService.java

public BlockState getBestBlockLocation(Observation observation, BlockInstance blockInstance,
        double blockDistanceFrom, double blockDistanceTo) {

    blockDistanceFrom = Math.floor(blockDistanceFrom / _threshold) * _threshold;
    blockDistanceTo = Math.ceil(blockDistanceTo / _threshold) * _threshold;

    BlockLocationKey key = new BlockLocationKey(blockInstance, blockDistanceFrom, blockDistanceTo);

    Map<BlockLocationKey, BlockState> m = _observationCache.getValueForObservation(observation,
            EObservationCacheKey.BLOCK_LOCATION);

    if (m == null) {
        m = new HashMap<BlockStateService.BlockLocationKey, BlockState>();
        _observationCache.putValueForObservation(observation, EObservationCacheKey.BLOCK_LOCATION, m);
    }//from  w  w w.  ja  v a  2s  .c  o m

    BlockState blockState = m.get(key);

    _cacheAccessCount++;

    if (blockState == null) {
        _cacheMissCount++;
        blockState = getUncachedBestBlockLocation(observation, blockInstance, blockDistanceFrom,
                blockDistanceTo);
        m.put(key, blockState);
    }

    //_log.info("cache: " + _cacheMissCount + " / " + _cacheAccessCount);

    return blockState;
}

From source file:de.ailis.wlandsuite.WebExtract.java

/**
 * Extracts the tilesets.//from w w w  .j av a2  s . c  om
 *
 * @param sourceDirectory
 *            The input directory
 * @param targetDirectory
 *            The output directory
 * @throws IOException
 *             When file operation fails.
 */

private void extractTilesets(final File sourceDirectory, final File targetDirectory) throws IOException {
    // Extract tilesets
    final File imagesDirectory = new File(targetDirectory, "images");
    imagesDirectory.mkdirs();
    for (int gameId = 1; gameId <= 2; gameId++) {
        final String filename = "allhtds" + gameId;

        log.info("Reading " + filename);
        final InputStream stream = new FileInputStream(new File(sourceDirectory, filename));
        try {
            final Htds htds = Htds.read(stream);

            int tilesetId = 0;
            log.info("Writing tileset " + tilesetId);
            for (final HtdsTileset tileset : htds.getTilesets()) {
                final List<Pic> tiles = tileset.getTiles();
                final int scale = this.scaleFilter.getScaleFactor();
                final BufferedImage out;
                final int outType = this.scaleFilter.getImageType();
                if (outType == -1)
                    out = new EgaImage(10 * 16 * scale,
                            (int) Math.ceil((double) tiles.size() / 10) * 16 * scale);
                else
                    out = new BufferedImage(10 * 16 * scale,
                            (int) Math.ceil((double) tiles.size() / 10) * 16 * scale, outType);
                final Graphics2D g = out.createGraphics();
                int i = 0;
                for (final Pic tile : tileset.getTiles()) {
                    g.drawImage(this.scaleFilter.scale(tile), i % 10 * 16 * scale, i / 10 * 16 * scale, null);
                    i++;
                }

                ImageIO.write(out, "png", new File(imagesDirectory, "tileset" + gameId + tilesetId + ".png"));
                tilesetId++;
            }
        } finally {
            stream.close();
        }
    }
}

From source file:com.rapidminer.operator.preprocessing.discretization.AbsoluteDiscretization.java

@Override
protected Collection<AttributeMetaData> modifyAttributeMetaData(ExampleSetMetaData emd, AttributeMetaData amd)
        throws UndefinedParameterError {
    AttributeMetaData newAMD = new AttributeMetaData(amd.getName(), Ontology.NOMINAL, amd.getRole());
    Set<String> valueSet = new TreeSet<String>();
    newAMD.setValueSet(valueSet, SetRelation.SUPERSET);
    if (getParameterAsInt(PARAMETER_RANGE_NAME_TYPE) == DiscretizationModel.RANGE_NAME_SHORT) {
        for (int i = 0; i < (int) Math.ceil(((double) emd.getNumberOfExamples().getNumber())
                / getParameterAsInt(PARAMETER_SIZE_OF_BINS)); i++) {
            valueSet.add("range" + (i + 1));
        }//from  ww w.ja  v a 2  s. c o  m
        switch (emd.getNumberOfExamples().getRelation()) {
        case AT_LEAST:
            newAMD.setValueSet(valueSet, SetRelation.SUPERSET);
            break;
        case AT_MOST:
            newAMD.setValueSet(valueSet, SetRelation.SUBSET);
            break;
        case EQUAL:
            newAMD.setValueSet(valueSet, SetRelation.EQUAL);
            break;
        case UNKNOWN:
            newAMD.setValueSet(valueSet, SetRelation.UNKNOWN);
            break;
        }
    }
    return Collections.singletonList(newAMD);
}

From source file:fiji.plugin.trackmate.action.brownianmotion.WalkerMethodEstimator.java

/**
 * /*  w w w .j  a v  a  2 s  . c  o m*/
 * @param data Containes the mean squared displacement and the Tracklength for each track. data[i][0] = MSD data[i][1] = Tracklength
 * @param temp Temperature of the suspension in kelvin
 * @param visk Viscosity of the suspension
 * @param framerate Framerate in hertz
 * @param maxdiameter The maximum diameter for the estimation
 */
public WalkerMethodEstimator(double[][] data, double temp, double visk, double framerate, int maxdiameter) {

    this.data = data;
    this.temp = temp;
    this.visk = visk;
    this.frameduration = 1 / framerate;

    minTrackLength = Integer.MAX_VALUE;
    maxTrackLength = Integer.MIN_VALUE;
    //msdMin = Double.MAX_VALUE;
    msdMax = Double.MIN_VALUE;
    //double convFact = Math.pow(10, -10);

    for (int i = 0; i < data.length; i++) {
        //10^-10 cm^2 -> cm^2
        //this.data[i][0] = this.data[i][0]*convFact; //- 4*17.562862475*17.562862475*Math.pow(10, -7)*Math.pow(10, -7); 
        if (data[i][0] > msdMax) {
            msdMax = data[i][0];
        }
        if (this.data[i][1] > maxTrackLength) {
            maxTrackLength = (int) this.data[i][1];
        }
        if (this.data[i][1] < minTrackLength) {
            minTrackLength = (int) this.data[i][1];
        }
        //IJ.log("MSD " + this.data[i][0]);
    }

    logMapK = new double[maxTrackLength + 1];
    logMapGammaK = new double[maxTrackLength + 1];
    java.util.Arrays.fill(logMapK, Double.NaN);
    java.util.Arrays.fill(logMapGammaK, Double.NaN);
    maxRadiusInNm = maxdiameter / 2.0;

    binNumber = (int) (maxRadiusInNm / binSizeInnm);
    histBinNumber = (int) Math.ceil(Math.sqrt(data.length));
    deltaB = msdMax / histBinNumber;

    histogramMSD = new double[histBinNumber];
    java.util.Arrays.fill(histogramMSD, 0);
    Nk = new int[maxTrackLength + 1];
    java.util.Arrays.fill(Nk, 0);
    for (int i = 0; i < data.length; i++) {
        int index = (int) this.data[i][1];
        Nk[index]++;

        int index2 = (int) Math.floor(data[i][0] / deltaB - 0.001);

        histogramMSD[index2]++;
    }
}

From source file:it.polimi.diceH2020.SPACE4CloudWS.ml.MLPredictor.java

private void calculatePrediction(SolutionPerJob spj) {
    JobMLProfile features = dataService.getMLProfile(spj.getId());
    if (features == null) {
        try {/*  w  w w  . j  a  va 2  s  . co m*/
            ObjectMapper mapper = new ObjectMapper();
            switch (dataService.getScenario().getTechnology()) {
            case SPARK: {
                String serialized = readJsonFile(ds4cSettings.getSparkModel());
                features = mapper.readValue(serialized, JobMLProfile.class);
                break;
            }
            case HADOOP: {
                String serialized = readJsonFile(ds4cSettings.getHadoopModel());
                features = mapper.readValue(serialized, JobMLProfile.class);
                break;
            }
            case STORM:
                throw new RuntimeException("MLPredictor cannot be used with STORM");
            default:
                throw new RuntimeException("Unexpected enum");
            }
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage());
        }
    }
    JobProfile profile = spj.getProfile();

    double deadline = spj.getJob().getD();
    double chi_c = calculateChi_c(features);
    double chi_h = calculateChi_h(features);
    double chi_0 = calculateChi_0(profile, features);
    int h = spj.getNumberUsers();

    double xi = calculateXi(spj);
    int c = (int) Math.ceil(chi_c / (deadline - chi_h * h - chi_0));

    logger.debug("[SVR] numContainers = ceil(chi_c/(deadline - chi_h*h - chi_0)) = ceil(" + chi_c + "/("
            + deadline + "-" + chi_h + "*" + h + "-" + chi_0 + ") = " + c);

    spj.setDuration(deadline);
    spj.updateNumberContainers(c);
    validate(spj);
}

From source file:no.met.jtimeseries.marinogram.MarinogramCurrentPlot.java

private XYPlot createPlot(TimeZone timezone, boolean plotCurrentDirection, boolean plotCurrentSpeed) {
    ChartPlotter plotter = new ChartPlotter();
    // default setting
    plotter.setHeight(this.getHeight());
    plotter.setWidth(this.getWidth());
    plotter.setPlotDefaultProperties("", "");
    Color currentSpeedColor = new Color(142, 25, 131);
    Color currentDirectionColor = new Color(142, 25, 131);
    // plot style
    PlotStyle.Builder currentStyleBuilder = new PlotStyle.Builder("Current");
    PlotStyle plotStyle;//from   w  ww.ja v  a2s  .  c o  m
    NumberPhenomenon currentDirection = getOceanForecastDataModel()
            .getPhenomenen(PhenomenonName.CurrentDirection.toString(), NumberPhenomenon.class);
    NumberPhenomenon currentSpeed = getOceanForecastDataModel()
            .getPhenomenen(PhenomenonName.CurrentSpeed.toString(), NumberPhenomenon.class);
    if (currentSpeed == null || currentDirection == null) {
        return null;
    }
    currentSpeed = currentSpeed.scaling(100);
    double tick = (currentSpeed.getMaxValue() - currentSpeed.getMinValue()) / 2;
    tick = Math.ceil(tick / 10) * 10;
    double lowBound = Math.floor(currentSpeed.getMinValue() / (tick)) * (tick);
    //The minimum scale is 0
    lowBound = lowBound < 0 ? 0 : lowBound;
    lowBound = lowBound - tick / 2;
    double upperBound = lowBound + tick * 4;

    // reference the range axis
    NumberAxis leftNumberAxis = new NumberAxis();
    leftNumberAxis.setLabel(messages.getString("parameter.current") + " (cm/s)");
    leftNumberAxis.setLabelPaint(currentSpeedColor);
    leftNumberAxis.setTickLabelPaint(currentSpeedColor);
    leftNumberAxis.setLowerBound(lowBound);
    leftNumberAxis.setUpperBound(upperBound);
    leftNumberAxis.setTickUnit(new NumberTickUnit(tick));

    NumberAxis rightNumberAxis = new NumberAxis();
    rightNumberAxis.setLabel(messages.getString("label.knots"));
    rightNumberAxis.setLabelPaint(currentSpeedColor);
    rightNumberAxis.setTickLabelPaint(currentSpeedColor);
    lowBound = lowBound / 100.0 / KNOT;
    upperBound = upperBound / 100.0 / KNOT;
    rightNumberAxis.setLowerBound(lowBound);
    rightNumberAxis.setUpperBound(upperBound);
    rightNumberAxis.setTickUnit(new NumberTickUnit(tick / 100.0 / KNOT));
    NumberFormat formatter = new DecimalFormat("#0.00");
    rightNumberAxis.setNumberFormatOverride(formatter);

    List<Date> shortTermTimeList = this.getShortTermTime(currentDirection.getTime().get(0));

    //set thte plot current speed color to be transparent if show current speed is false
    if (!plotCurrentSpeed) {
        currentSpeedColor = new Color(0, 0, 0, 0);
    }

    // plot style
    BasicStroke dottedStroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 2.0f,
            new float[] { 2.0f, 6.0f }, 0.0f);
    plotStyle = currentStyleBuilder.spline(SplineStyle.HYBRID).stroke(dottedStroke)
            .seriesColor(currentSpeedColor).numberAxis(leftNumberAxis).nonNegative(true).build();

    //Draw the current direction even if plotCurrentSpeed is false (but with transparent in such a case)
    //for the purpose to keep the same background grid and tick label on the y-axis 
    //no matter the wave height is shown or not
    plotter.addLineChart(TimeBase.SECOND, currentSpeed, plotStyle);

    plotter.getPlot().setRangeAxis(1, rightNumberAxis);
    plotter.getPlot().setOutlineVisible(true);

    Date minDate = shortTermTimeList.get(0);
    Date maxDate = shortTermTimeList.get(shortTermTimeList.size() - 1);
    plotter.setDomainRange(minDate, maxDate);
    plotter.setDomainDateFormat(timezone, "HH");
    // set domain range after (must) plot all the data
    plotter.addHourBasedDomainGridLines();
    // invisible domain axis
    plotter.getPlot().getDomainAxis().setTickLabelsVisible(false);
    // add markers
    plotter.addDomainMarkers(shortTermTimeList, timezone, locale);

    if (plotCurrentDirection) {
        List<Date> symbolTimes = Utility.filterMinimumHourInterval(currentDirection.getTime(), 2, 1);
        InListFromDateFilter symbolTimesFilter = new InListFromDateFilter(symbolTimes);
        currentDirection.filter(symbolTimesFilter);
        currentSpeed = null;
        if (plotCurrentSpeed) {
            currentSpeed = getOceanForecastDataModel().getPhenomenen(PhenomenonName.CurrentSpeed.toString(),
                    NumberPhenomenon.class);
            currentSpeed.filter(symbolTimesFilter);
            currentSpeed = currentSpeed.scaling(1 / 100.0 / KNOT);
        }

        plotStyle = currentStyleBuilder.seriesColor(currentDirectionColor).build();
        plotter.addArrowDirectionPlot(currentDirection, currentSpeed, 2, plotStyle);
    }
    plotter.getPlot().setRangeZeroBaselineVisible(false);

    return plotter.getPlot();

}

From source file:com.srikanthps.HbaseBenchmarking.java

private static void runTest(Class rowCreatorClass, long startingRowKey, int numRecordsToInsert,
        long numThreadsToUse, String data)
        throws InterruptedException, InstantiationException, IllegalAccessException {

    timingStats.clear();/*from w ww .jav  a  2s .co m*/

    int numRecordsPerThread = (int) Math.ceil(((double) numRecordsToInsert) / numThreadsToUse);

    List<Thread> threads = new ArrayList<Thread>();
    for (int i = 0; i < numThreadsToUse; i++) {
        RowCreator c = (RowCreator) rowCreatorClass.newInstance();
        c.setData(data);
        c.setNextRowkey(startingRowKey);
        c.setNumRecordsToInsert(numRecordsPerThread);

        Thread t = new Thread(c);
        threads.add(t);
        t.start();
    }

    for (int i = 0; i < numThreadsToUse; i++) {
        threads.get(i).join();
    }

    System.out.println(StringUtils.rightPad(rowCreatorClass.newInstance().toString(), 50) + ","
            + format(numThreadsToUse, VALUE_LEFT_PAD) + "," + format(timingStats.getN(), VALUE_LEFT_PAD) + ","
            + format(timingStats.getMean(), VALUE_LEFT_PAD) + ","
            + format(timingStats.getStandardDeviation(), VALUE_LEFT_PAD) + ","
            + format(timingStats.getMax(), VALUE_LEFT_PAD) + "," + format(timingStats.getMin(), VALUE_LEFT_PAD)
            + "," + format(timingStats.getPercentile(80.0), VALUE_LEFT_PAD) + ","
            + format(timingStats.getPercentile(90.0), VALUE_LEFT_PAD));
}