Example usage for java.lang Double intValue

List of usage examples for java.lang Double intValue

Introduction

In this page you can find the example usage for java.lang Double intValue.

Prototype

public int intValue() 

Source Link

Document

Returns the value of this Double as an int after a narrowing primitive conversion.

Usage

From source file:org.motechproject.server.service.impl.ExpectedObsSchedule.java

protected Integer getLargestDoseValue(List<Obs> obsList) {
    Double largestDoseValue = null;
    for (Obs obs : obsList) {
        Double obsValue = obs.getValueNumeric();
        if (obsValue != null) {
            if (largestDoseValue == null || obsValue > largestDoseValue) {
                largestDoseValue = obsValue;
            }// w  ww.  ja  va2s  . c  om
        }
    }
    if (largestDoseValue != null) {
        return largestDoseValue.intValue();
    }
    return null;
}

From source file:jbosscomp.view.backing.Comparator.java

public BigDecimal getSubscriptionCost() {
    RichInputNumberSpinbox rinsTotalJBossCores = (RichInputNumberSpinbox) get(
            "#{backingBeanScope.backing_comparator.jbossCoresY1}");
    BigDecimal totalCores = new BigDecimal(rinsTotalJBossCores.getValue().toString());
    Double index = totalCores.doubleValue() / 16.0;
    index = Math.ceil(index);/*from  w  w w  .  j  av a2  s.  c  o  m*/
    int i = index.intValue();
    if (i >= subscriptionCosts.length)
        i = 0;
    return new BigDecimal(subscriptionCosts[i]);
}

From source file:com.aurel.track.move.ItemMoveBL.java

/**
 * In Gantt we are handling link lags: day, week, month,
 * This method returns link lag in days.
 * Foe ex: -1) 1 mo link lag is 20 work day.
 *          -2) 1 w link lag is 5 work days
 * @param actualLinkBean//from   w ww .j  a va  2  s.c o  m
 * @param workItemID
 * @return
 */
public static int getLinkLagInDays(TWorkItemLinkBean actualLinkBean, Double hoursPerWorkday) {
    Double convertedLinkLag = LinkLagBL.getUILinkLagFromMinutes(actualLinkBean.getLinkLag(),
            actualLinkBean.getLinkLagFormat(), hoursPerWorkday);
    int linkLagInDays = 0;
    Integer actualLinkLagFormat = actualLinkBean.getLinkLagFormat();
    if (actualLinkLagFormat == null) {
        actualLinkLagFormat = MsProjectExchangeDataStoreBean.LAG_FORMAT.d;
    }
    switch (actualLinkLagFormat) {
    case MsProjectExchangeDataStoreBean.LAG_FORMAT.d:
    case MsProjectExchangeDataStoreBean.LAG_FORMAT.ed:
        linkLagInDays = convertedLinkLag.intValue();
        break;
    case MsProjectExchangeDataStoreBean.LAG_FORMAT.mo:
    case MsProjectExchangeDataStoreBean.LAG_FORMAT.emo:
        linkLagInDays = convertedLinkLag.intValue() * 20;
        break;
    case MsProjectExchangeDataStoreBean.LAG_FORMAT.w:
    case MsProjectExchangeDataStoreBean.LAG_FORMAT.ew:
        linkLagInDays = convertedLinkLag.intValue() * 5;
        break;
    }
    return linkLagInDays;
}

From source file:nl.b3p.viewer.image.CombineWMTSUrl.java

public CombineStaticImageUrl createTile(ImageBbox imageBbox, Bbox tileBbox, int tileX, int tileY, int matrixId,
        Double imgPosX, Double imgPosY) {
    CombineStaticImageUrl img = new CombineStaticImageUrl();
    TileMatrix tm = set.getMatrices().get(matrixId);
    String tileUrl = createUrl(imageBbox, tileBbox, tileX, tileY, matrixId);
    img.setUrl(tileUrl);/*w w w. j  av  a 2s  . c o  m*/
    img.setHeight((int) (tm.getTileHeight() / ratio));
    img.setWidth((int) (tm.getTileWidth() / ratio));
    img.setBbox(tileBbox);
    img.setX(imgPosX.intValue());
    img.setY(imgPosY.intValue());
    img.setAlpha(this.getAlpha());
    return img;
}

From source file:org.jahia.utils.maven.plugin.contentgenerator.ContentGeneratorService.java

/**
 * Calculates the number of pages needed, used to know how much articles we
 * will need//from w  w w . j a v  a  2s.  c  o  m
 * 
 * @param nbPagesTopLevel
 * @param nbLevels
 * @param nbPagesPerLevel
 * @return number of pages needed
 */
public Integer getTotalNumberOfPagesNeeded(Integer nbPagesTopLevel, Integer nbLevels, Integer nbPagesPerLevel) {
    Double nbPages = new Double(0);
    for (double d = nbLevels; d > 0; d--) {
        nbPages += Math.pow(nbPagesPerLevel.doubleValue(), d);
    }
    nbPages = nbPages * nbPagesTopLevel + nbPagesTopLevel;

    return new Integer(nbPages.intValue());
}

From source file:eu.europa.esig.dss.XmlDom.java

public long getCountValue(final String xPath, final Object... params) {

    String xpathString = format(xPath, params);
    try {//from   w  w w  .j  a v a2  s . c om

        XPathExpression xPathExpression = createXPathExpression(xpathString);
        Double number = (Double) xPathExpression.evaluate(rootElement, XPathConstants.NUMBER);
        return number.intValue();
    } catch (XPathExpressionException e) {

        throw new RuntimeException(e);
    }
}

From source file:org.uzebox.tools.converters.gfx.Main.java

private static void doFrequencyTable() throws Exception {
    double cpuFreq = 28636360;
    double mixingPeriod = (1 / cpuFreq) * 1820;
    double waveCyclePeriod = mixingPeriod * 256;
    File outFile = new File(path + "steptable.inc");
    String notes[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };

    StringBuffer str = new StringBuffer();
    str.append("// Step Table\n");
    str.append("// ---------------------------\r\n");
    str.append("// CPU=28.63636Mhz,");
    str.append("// Mixing Freqency=" + (1 / mixingPeriod) + " Hz\r\n\r\n");

    //f = 212k/12  440 Hz = 2k  440 Hz
    //freq = 440 * 2^((n-69)/12)

    double a4Freq = 440;
    int currNote = 0;
    for (int note = 0; note < 127; note++) {
        double dblNote = new Double(note).doubleValue();
        double noteFreq = a4Freq * Math.pow(2, (dblNote - 69) / 12);

        double step = (noteFreq / (1 / waveCyclePeriod));
        Double dblConv = new Double(Math.round(step * 256));
        int stepConv = dblConv.intValue();

        str.append(".word 0x" + pad(Integer.toHexString(stepConv)));
        str.append(" // Note: " + note + " (" + notes[(currNote % 12)] + "-" + ((currNote / 12) + 1)
                + "), MIDI note: " + note + ", Freq:" + noteFreq + ", Step:" + step + "\r\n");
        currNote++;//from  w  ww.  j av a 2 s.c om

    }

    FileUtils.writeStringToFile(outFile, str.toString());
    System.out.println("Processing file " + outFile.getName() + "...Done!");

}

From source file:ubic.gemma.analysis.expression.coexpression.links.LinkAnalysis.java

/**
 * Writes two flies: one the actual probe degrees, and the other a histogram (dist)
 *///from   ww w.j ava  2 s.co m
private void writeProbeDegreeDistribution() {

    File outputDir = getOutputDir();

    if (outputDir == null)
        return;

    String distPath = outputDir + File.separator + expressionExperiment.getShortName() + ".degreeDist.txt";
    String path = outputDir + File.separator + expressionExperiment.getShortName() + ".degrees.txt";

    File outputFile = new File(path);
    if (outputFile.exists()) {
        outputFile.delete();
    }

    File outputDistFile = new File(distPath);
    if (outputDistFile.exists()) {
        outputDistFile.delete();
    }

    try {
        FileWriter out = new FileWriter(outputFile);

        out.write("# Probe degree statistics (before filtering by probeDegreeThreshold)\n");
        out.write("# date=" + (new Date()) + "\n");
        out.write("# exp=" + expressionExperiment + " " + expressionExperiment.getShortName() + "\n");
        out.write("ProbeID\tProbeName\tNumLinks\n");

        for (Integer i : probeDegreeMap.keySet()) {
            CompositeSequence probe = this.getProbe(i);
            out.write(probe.getId() + "\t" + probe.getName() + "\t" + probeDegreeMap.get(i) + "\n");
        }

        out.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    Histogram hist = new Histogram("foo", 100, 0, 1000);
    for (Integer i : probeDegreeMap.values()) {
        hist.fill(i.doubleValue());
    }

    double[] counts = hist.getArray();
    try {
        FileWriter out = new FileWriter(outputDistFile);

        int d = (int) hist.min();
        int step = (int) hist.stepSize();

        out.write("# Probe degree histogram (before filtering by probeDegreeThreshold)\n");
        out.write("# date=" + (new Date()) + "\n");
        out.write("# exp=" + expressionExperiment + " " + expressionExperiment.getShortName() + "\n");
        out.write("Bin\tCount\n");

        for (int i = 0; i < counts.length; i++) {
            Double v = counts[i];
            out.write(d + "\t" + v.intValue() + "\n");
            d += step;
        }

        out.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

}

From source file:org.eclipse.nebula.widgets.nattable.layer.SizeConfig.java

/**
 * Sets the given size for the given position. This method can be called manually for configuration
 * via {@link DataLayer} and will be called on resizing within the rendered UI. This is why there
 * is a check for percentage configuration. If this {@link SizeConfig} is configured to not use
 * percentage sizing, the size is taken as is. If percentage sizing is enabled, the given size
 * will be calculated to percentage value based on the already known pixel values.
 * <p>/* w  w  w  . j a v  a2 s.  co m*/
 * If you want to use percentage sizing you should use {@link SizeConfig#setPercentage(int, int)}
 * for manual size configuration to avoid unnecessary calculations.
 * 
 * @param position The position for which the size should be set.
 * @param size The size in pixels to set for the given position.
 */
public void setSize(int position, int size) {
    if (size < 0) {
        throw new IllegalArgumentException("size < 0"); //$NON-NLS-1$
    }
    if (isPositionResizable(position)) {
        //check whether the given value should be remembered as is or if it needs to be calculated
        if (!isPercentageSizing(position)) {
            sizeMap.put(position, size);
        } else {
            if (availableSpace > 0) {
                Double percentage = ((double) size * 100) / availableSpace;
                sizeMap.put(position, percentage.intValue());
            }
        }

        if (isPercentageSizing())
            calculatePercentages(availableSpace, realSizeMap.size());
    }
}

From source file:ua.aits.Carpath.controller.AjaxController.java

@RequestMapping(value = { "/system/routesByType/", "/system/routesByType", "/Carpath/system/routesByType/",
        "/Carpath/system/routesByType" }, method = RequestMethod.GET)
public @ResponseBody ResponseEntity<String> routesByType(HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    request.setCharacterEncoding("UTF-8");
    String type = request.getParameter("type");
    String value = request.getParameter("value");
    int countPage = Integer.parseInt(request.getParameter("count"));
    int page = Integer.parseInt(request.getParameter("page"));
    List<RouteModel> tempRoutes = routes.getAllRoutesSystem(type, value);
    String returnHTML = "";
    String pagination = "<tr><td colspan=\"10\" class=\"pagination\">";
    int first = (countPage * page) - countPage;
    int second = countPage * page;
    if (countPage * page > tempRoutes.size()) {
        first = (page - 1) * countPage;//  ww  w.  j  a va2  s . co m
        second = tempRoutes.size();
    }
    Integer count = tempRoutes.size() - (first);
    List<RouteModel> tempS = tempRoutes.subList(first, second);
    for (RouteModel temp : tempS) {
        String check = "checked";
        String is_publish = "publish";
        System.out.println(temp.id);
        if (temp.publish == 0) {
            check = "";
            is_publish = "";
        }
        returnHTML = returnHTML + "<tr><td class=\"admin-table-count\">" + count.toString() + "</td>"
                + "      <td class=\"admin-table-cell-title\"><a href=\"http://www.carpathianroad.com/en/routes/"
                + temp.id + "\" target=\"_blank\">" + temp.title + "</a></td>"
                + "      <td class=\"admin-table-cell\">" + temp.public_country + "</td>"
                + "      <td class=\"article-type admin-table-cell\">" + temp.textType + "</td>"
                + "      <td class=\"article-publish " + is_publish
                + "\"><input type=\"checkbox\" data-size=\"mini\" class=\"publish-checkbox\" data-id=\""
                + temp.id + "\" name=\"my-checkbox\" " + check + "></td>" + "<td class=\"" + is_publish + "\">"
                + "          <a class=\"edit-button\" href=\"" + Constants.URL + "system/routes/edit/" + temp.id
                + "\"><img class=\"edit-delete\" src=\"" + Constants.URL + "img/edit.png\" /></a>"
                + "      </td>" + "      <td class=\"" + is_publish + "\">" + "          <a href=\""
                + Constants.URL + "system/routes/delete/" + temp.id + "\"><img class=\"edit-delete\" src=\""
                + Constants.URL + "img/delete.png\" /></a>" + "      </td>" + "    </tr>";
        count--;
    }
    Double x = Math.ceil((double) tempRoutes.size() / countPage);
    int pages = x.intValue();
    System.out.println(x + "///" + count / countPage + "///" + pages + "///" + count + "////" + countPage);
    for (int i = 1; i <= pages; i++) {
        pagination = pagination + "<a>" + i + "</a>";
    }
    returnHTML = returnHTML + pagination + "</td></tr>";
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.add("Content-Type", "application/json; charset=utf-8");
    return new ResponseEntity<>(returnHTML, responseHeaders, HttpStatus.CREATED);
}