Example usage for java.lang Double doubleValue

List of usage examples for java.lang Double doubleValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public double doubleValue() 

Source Link

Document

Returns the double value of this Double object.

Usage

From source file:org.sakaiproject.tool.gradebook.ui.FeedbackOptionsBean.java

private void initGradeRows() {
    // Set up UI table view.
    gradeRows = new ArrayList();
    GradeMapping selectedGradeMapping = localGradebook.getSelectedGradeMapping();
    for (Iterator iter = selectedGradeMapping.getGrades().iterator(); iter.hasNext();) {
        String grade = (String) iter.next();

        // Bottom grades (with a lower bound of 0%) and manual-only
        // grades (which have no percentage equivalent) are not
        // editable.
        Double d = selectedGradeMapping.getDefaultBottomPercents().get(grade);
        boolean editable = ((d != null) && (d.doubleValue() > 0.0));
        gradeRows.add(new GradeRow(selectedGradeMapping, grade, editable));
    }/*from   ww w.  j a v  a  2s. c  o  m*/
}

From source file:org.sakaiproject.gradebookng.tool.panels.AssignmentStatisticsPanel.java

private String constructMedianLabel(final List<Double> allGrades, final Assignment assignment) {
    final double median = calculateMedian(allGrades);
    final String medianFormatted = FormatHelper.formatDoubleToDecimal(Double.valueOf(median));

    if (GradingType.PERCENTAGE.equals(this.gradingType)) {
        return (new StringResourceModel("label.percentage.valued", null, new Object[] { medianFormatted }))
                .getString();/*from   w  w  w. j a  va  2  s . co m*/
    }

    final Double total = assignment.getPoints();
    final String percentage = FormatHelper.formatDoubleAsPercentage(100 * (median / total.doubleValue()));

    return (new StringResourceModel("label.statistics.medianvalue", null,
            new Object[] { medianFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage }))
                    .getString();
}

From source file:org.sakaiproject.gradebookng.tool.panels.AssignmentStatisticsPanel.java

private String constructLowestLabel(final List<Double> allGrades, final Assignment assignment) {
    final double lowest = Collections.min(allGrades);
    final String lowestFormatted = FormatHelper.formatDoubleToDecimal(Double.valueOf(lowest));

    if (GradingType.PERCENTAGE.equals(this.gradingType)) {
        return (new StringResourceModel("label.percentage.valued", null, new Object[] { lowestFormatted }))
                .getString();/*from w w  w.j  av a2s  .c  om*/
    }

    final Double total = assignment.getPoints();
    final String percentage = FormatHelper.formatDoubleAsPercentage(100 * (lowest / total.doubleValue()));

    return (new StringResourceModel("label.statistics.lowestvalue", null,
            new Object[] { lowestFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage }))
                    .getString();
}

From source file:org.sakaiproject.gradebookng.tool.panels.AssignmentStatisticsPanel.java

private String constructAverageLabel(final List<Double> allGrades, final Assignment assignment) {
    final double average = calculateAverage(allGrades);
    final String averageFormatted = FormatHelper.formatDoubleToDecimal(Double.valueOf(average));

    if (GradingType.PERCENTAGE.equals(this.gradingType)) {
        return (new StringResourceModel("label.percentage.valued", null, new Object[] { averageFormatted }))
                .getString();/*from   w  ww  .  j  a va  2  s.c o m*/
    }

    final Double total = assignment.getPoints();
    final String percentage = FormatHelper.formatDoubleAsPercentage(100 * (average / total.doubleValue()));

    return (new StringResourceModel("label.statistics.averagevalue", null,
            new Object[] { averageFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage }))
                    .getString();
}

From source file:org.sakaiproject.gradebookng.tool.panels.AssignmentStatisticsPanel.java

private String constructHighestLabel(final List<Double> allGrades, final Assignment assignment) {
    final double highest = Collections.max(allGrades);
    final String highestFormatted = FormatHelper.formatDoubleToDecimal(Double.valueOf(highest));

    if (GradingType.PERCENTAGE.equals(this.gradingType)) {
        return (new StringResourceModel("label.percentage.valued", null, new Object[] { highestFormatted }))
                .getString();/* www .ja v  a  2 s. c  om*/
    }

    final Double total = assignment.getPoints();
    final String percentage = FormatHelper.formatDoubleAsPercentage(100 * (highest / total.doubleValue()));

    return new StringResourceModel("label.statistics.highestvalue", null,
            new Object[] { highestFormatted, FormatHelper.formatGrade(String.valueOf(total)), percentage })
                    .getString();
}

From source file:org.jactr.core.chunk.five.DefaultSubsymbolicChunk5.java

/**
 * Gets the Similarity attribute of the DefaultSubsymbolicChunk5 object
 * /*  w ww  .j a va  2 s .  c  om*/
 * @param c
 *          Description of Parameter
 * @return The Similarity value
 * @since
 */
public double getSimilarity(IChunk c) {
    if (c == null)
        return Double.NaN;

    try {
        readLock().lock();
        Double rtn = _similarityMap.get(c);
        if (rtn == null)
            return Double.NaN;
        return rtn.doubleValue();
    } finally {
        readLock().unlock();
    }

}

From source file:de.hybris.platform.acceleratorstorefrontcommons.forms.validation.ReviewValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final ReviewForm reviewForm = (ReviewForm) object;
    final String headLine = reviewForm.getHeadline();
    final String comment = reviewForm.getComment();
    final Double rating = reviewForm.getRating();

    if (StringUtils.isEmpty(headLine) || StringUtils.length(headLine) > 255) {
        errors.rejectValue("headline", "review.headline.invalid");
    }/* ww  w. j a  v  a2 s  .co m*/

    if (StringUtils.isEmpty(comment) || StringUtils.length(comment) > 4000) {
        errors.rejectValue("comment", "review.comment.invalid");
    }

    if (rating == null || rating.doubleValue() < 0.5 || rating.doubleValue() > 5) {
        errors.rejectValue("rating", "review.rating.invalid");
    }
}

From source file:org.training.storefront.forms.validation.ReviewValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final ReviewForm reviewForm = (ReviewForm) object;
    final String headLine = reviewForm.getHeadline();
    final String comment = reviewForm.getComment();
    final Double rating = reviewForm.getRating();

    if (StringUtils.isEmpty(headLine) || StringUtils.length(headLine) > 255) {
        errors.rejectValue("headline", "review.headline.invalid");
    }/* ww  w .j a v a2 s .  c o  m*/

    if (StringUtils.isEmpty(comment) || StringUtils.length(comment) > 4000) {
        errors.rejectValue("comment", "review.comment.invalid");
    }

    if (rating == null || rating.doubleValue() < 1 || rating.doubleValue() > 5) {
        errors.rejectValue("rating", "review.rating.invalid");
    }
}

From source file:ome.server.itests.query.pojos.QueryTest.java

private void assertFloatsNotRounded(double dbl) {
    Correction correction = iQuery.findAll(Correction.class, null).get(0);
    Immersion immersion = iQuery.findAll(Immersion.class, null).get(0);

    Objective o = new Objective();
    Instrument instrument = new Instrument();
    o.setCorrection(correction);//ww  w .  j  a  v  a2 s  .com
    o.setImmersion(immersion);
    o.setInstrument(instrument);
    // o.setLensNA(new Float(dbl));
    o.setLensNA(dbl);

    Objective t1 = iUpdate.saveAndReturnObject(o);

    // Test value via jdbc
    String jdbcQuery = "SELECT lensNa FROM Objective WHERE id = :id";
    Float lensNA = (Float) iQuery.projection(jdbcQuery, new Parameters().addId(t1.getId())).get(0)[0];
    assertEquals(dbl, lensNA.floatValue(), 0.01);
    try {
        assertEquals(dbl, lensNA.floatValue(), Float.MIN_VALUE);
    } catch (AssertionFailedError e) {
        // This is what fails!!
    }

    // now test is with double which is our chosen solution
    Double lensNADoubled = (Double) iQuery.projection(jdbcQuery, new Parameters().addId(t1.getId())).get(0)[0];
    assertEquals(dbl, lensNADoubled.doubleValue(), 0.01);
    assertEquals(dbl, lensNADoubled.doubleValue(), Float.MIN_VALUE);
    assertEquals(dbl, lensNADoubled.doubleValue(), Double.MIN_VALUE);

    // Test value return by iUpdate
    // Now changing these to doubleValue() post #1150 fix.
    assertEquals(dbl, t1.getLensNA().doubleValue(), 0.001);
    assertEquals(dbl, t1.getLensNA().doubleValue(), Float.MIN_VALUE);
    assertEquals(dbl, t1.getLensNA().doubleValue());

    // Test via query
    Objective t2 = iQuery.find(Objective.class, o.getId());
    assertEquals(dbl, t2.getLensNA().doubleValue());
}

From source file:org.polymap.wbv.ui.reports.Report103.java

@Override
public JasperReportBuilder build() throws DRException, JRException, IOException {
    ReportTemplateBuilder templateBuilder = template();
    templateBuilder.setGroupShowColumnHeaderAndFooter(false);
    templateBuilder.setGroupHeaderLayout(GroupHeaderLayout.VALUE);
    templateBuilder.setSubtotalLabelPosition(Position.BOTTOM);
    templateBuilder/*  w w  w.  j  a v a 2s  .com*/
            .setGroupStyle(stl.style(stl.style().bold()).setHorizontalAlignment(HorizontalAlignment.LEFT));
    templateBuilder
            .setGroupTitleStyle(stl.style(stl.style().bold()).setHorizontalAlignment(HorizontalAlignment.LEFT));

    List<Flurstueck> flurstuecke = new ArrayList<Flurstueck>();

    // nur den ersten, weil sonst Subreports noetig waeren
    Waldbesitzer firstWb = null;

    Iterator<? extends Composite> iter = gesuchteWaldbesitzer().iterator();
    Composite entity = iter.next();
    if (entity instanceof Waldbesitzer) {
        firstWb = (Waldbesitzer) entity;
        firstWb.flurstuecke(revier.get()).forEach(fst -> flurstuecke.add(fst));
    }

    final Waldbesitzer wb = firstWb;

    // datasource
    JsonBuilder jsonBuilder = new JsonBuilder(flurstuecke) {

        @Override
        protected Object buildJson(Object value) {
            Object result = super.buildJson(value);
            //
            if (value instanceof Flurstueck) {
                JSONObject resultObj = (JSONObject) result;
                Flurstueck flurstueck = (Flurstueck) value;
                resultObj.put("name", besitzerName(wb));
                resultObj.put("adresse", calculateAdresse(wb));
                if (flurstueck.gemarkung.get() != null) {
                    String gemeinde = flurstueck.gemarkung.get().gemeinde.get();
                    resultObj.put("gemeinde", gemeinde);
                    String gemarkung = flurstueck.gemarkung.get().gemarkung.get();
                    resultObj.put("gemarkung", gemarkung);
                }
                String flstNr = flurstueck.zaehlerNenner.get();
                resultObj.put("flst_nr", flstNr);
                Double gesamtFlaeche = flurstueck.flaeche.get();
                Double waldFlaeche = flurstueck.flaecheWald.get();
                resultObj.put("gesamtFlaeche", gesamtFlaeche != null ? gesamtFlaeche.doubleValue() : 0d);
                resultObj.put("flaecheWaldAnteilig", waldFlaeche != null ? waldFlaeche.doubleValue() : 0d);
                resultObj.put("nutzungsart", "");
                resultObj.put("forstort", "");
                resultObj.put("nutzungsflaeche", "");
            }
            return result;
        }
    };

    TextColumnBuilder<String> gemeindeColumn = col.column("Gemeinde", "gemeinde", type.stringType())
            .setStyle(stl.style().bold().setBottomBorder(stl.pen1Point()));
    TextColumnBuilder<String> gemarkungColumn = col.column("Gemarkung", "gemarkung", type.stringType())
            .setStyle(stl.style().bold().setBottomBorder(stl.pen1Point()));
    TextColumnBuilder<String> flstnrColumn = col.column("Flst-Nr", "flst_nr", type.stringType())
            .setStyle(stl.style().bold());
    TextColumnBuilder<Double> gesamtFlaecheColumn = col
            .column("Gesamtflche", "gesamtFlaeche", type.doubleType()).setValueFormatter(nf);
    TextColumnBuilder<Double> waldFlaecheColumn = col
            .column("davon Wald", "flaecheWaldAnteilig", type.doubleType()).setValueFormatter(nf);
    TextColumnBuilder<String> nutzungsartColumn = col.column("Nutzungsart", "nutzungsart", type.stringType())
            .setStyle(stl.style().bold());
    TextColumnBuilder<String> forstortColumn = col.column("Forstort", "forstort", type.stringType())
            .setStyle(stl.style().bold());
    TextColumnBuilder<String> nutzungsflaecheColumn = col
            .column("Nutzungsflche", "nutzungsflaeche", type.stringType()).setStyle(stl.style().bold());

    ColumnTitleGroupBuilder titleGroup1 = grid.titleGroup("Gemeinde \n   Gemarkung", gemeindeColumn,
            gemarkungColumn);

    ColumnGroupBuilder gemeindeGroupBuilder = Groups.group(gemeindeColumn).setPadding(5);
    ColumnGroupBuilder gemarkungGroupBuilder = Groups.group(gemarkungColumn).setPadding(5);

    JasperReportBuilder report = report().setTemplate(templateBuilder)
            .setDataSource(new JsonDataSource(jsonBuilder.run()))
            .setPageFormat(PageType.A4, PageOrientation.PORTRAIT)
            .title(cmp.text("Waldflchen eines Waldbesitzers").setStyle(titleStyle),
                    cmp.text(df.format(new Date())).setStyle(headerStyle),
                    cmp.text("Forstbezirk: Mittelsachsen").setStyle(headerStyle),
                    cmp.text("Revier: " + getRevier() + " / Abfrage: \"" + getQuery() + "\"")
                            .setStyle(headerStyle),
                    cmp.text(besitzerName(firstWb)).setStyle(headerStyle),
                    cmp.text(calculateAdresse(firstWb)).setStyle(headerStyle))
            .pageFooter(cmp.pageXofY().setStyle(footerStyle))
            // number of page
            .setDetailOddRowStyle(highlightRowStyle).setColumnTitleStyle(columnTitleStyle)
            .setColumnTitleStyle(columnTitleStyle).addGroup(gemeindeGroupBuilder)
            .addGroup(gemarkungGroupBuilder)
            .columns(flstnrColumn, gesamtFlaecheColumn, waldFlaecheColumn, nutzungsartColumn, forstortColumn,
                    nutzungsflaecheColumn)
            .columnGrid(titleGroup1, flstnrColumn, gesamtFlaecheColumn, waldFlaecheColumn, nutzungsartColumn,
                    forstortColumn, nutzungsflaecheColumn)
            .subtotalsAtGroupHeader(gemeindeGroupBuilder, sbt.sum(gesamtFlaecheColumn).setValueFormatter(nf),
                    sbt.sum(waldFlaecheColumn).setValueFormatter(nf))
            .subtotalsAtGroupHeader(gemarkungGroupBuilder, sbt.sum(gesamtFlaecheColumn).setValueFormatter(nf),
                    sbt.sum(waldFlaecheColumn).setValueFormatter(nf))
            .subtotalsAtSummary().sortBy(asc(gemeindeColumn), asc(gemarkungColumn));
    return report;
}