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:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationPropertiesWithDoubleArray() {
    ConfigurationPropertiesWithArray config = prepareConfigurationPropertiesWithArray();

    Double doubleValue = config.doubleArray[0];

    assertEquals(Double.class, doubleValue.getClass());
    assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1);
    assertEquals(3, config.doubleArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithArrayTest.java

@Test
public void testConfigurationXMLWithDoubleArray() {
    ConfigurationXMLWithArray config = prepareConfigurationXMLWithArray();

    Double doubleValue = config.doubleArray[0];

    assertEquals(Double.class, doubleValue.getClass());
    assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1);
    assertEquals(3, config.doubleArray.length);
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationPropertiesWithDoubleList() {
    ConfigurationPropertiesWithList config = prepareConfigurationPropertiesWithList();

    Double doubleValue = config.doubleList.get(0);

    assertEquals(Double.class, doubleValue.getClass());
    assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1);
    assertEquals(3, config.doubleList.size());
}

From source file:br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoaderWithListTest.java

@Test
public void testConfigurationXMLWithDoubleList() {
    ConfigurationXMLWithList config = prepareConfigurationXMLWithList();

    Double doubleValue = config.doubleList.get(0);

    assertEquals(Double.class, doubleValue.getClass());
    assertEquals(Double.MAX_VALUE, doubleValue.doubleValue(), 1);
    assertEquals(3, config.doubleList.size());
}

From source file:com.nagarro.core.v1.controller.ProductsController.java

private GeoPoint createGeoPoint(final Double latitude, final Double longitude) {
    final GeoPoint point = new GeoPoint();
    point.setLatitude(latitude.doubleValue());
    point.setLongitude(longitude.doubleValue());

    return point;
}

From source file:org.rhq.enterprise.gui.legacy.taglib.display.MetricDecorator.java

@Override
public String decorate(Object obj) throws Exception {
    try {/*  w w w . j  a v  a2s. c o m*/
        // if the metric value is empty, converting to a Double
        // will give a value of 0.0. this makes it impossible for
        // us to distinguish further down the line whether the
        // metric was actually collected with a value of 0.0 or
        // whether it was not collected at all. therefore, we'll
        // let m be null if the metric was not collected, and
        // we'll check for null later when handling the not-avail
        // case.
        // PR: 7588
        Double m = null;
        if (obj != null) {
            String mval = (String) evalAttr("metric", obj.toString(), String.class);
            if ((mval != null) && !mval.equals("")) {
                m = new Double(mval);
            }
        }

        Locale l = RequestUtils.retrieveUserLocale(context, locale);

        StringBuffer buf = new StringBuffer();

        if (((m == null) || Double.isNaN(m.doubleValue()) || Double.isInfinite(m.doubleValue()))
                && (defaultKey != null)) {
            buf.append(RequestUtils.message(context, bundle, l.toString(), defaultKey));
        } else if (unit.equals("ms")) {
            // we don't care about scaling and such. we just want
            // to show every metric in seconds with millisecond
            // resolution
            String formatted = UnitsFormat.format(
                    new UnitNumber(m.doubleValue(), UnitsConstants.UNIT_DURATION, ScaleConstants.SCALE_MILLI))
                    .toString();
            buf.append(formatted);
        } else {
            MeasurementUnits targetUnits = MeasurementUnits.valueOf(unit);
            Double dataValue = m.doubleValue();
            String formatted = MeasurementConverter.format(dataValue, targetUnits, true);

            buf.append(formatted);
        }

        return buf.toString();
    } catch (JspException je) {
        log.error(je);
        throw je;
    } catch (Exception e) {
        log.error(e);
        throw new JspException(e);
    }
}

From source file:com.epam.cme.facades.bundle.impl.DefaultGuidedSellingFacade.java

protected ProductSearchPageData<SearchStateData, ProductData> enrichSearchResult(
        final ProductSearchPageData<SearchStateData, ProductData> searchPageData, final String componentId,
        final String componentVersion, final Integer bundleNo) {
    final CartModel cartModel = getCartService().getSessionCart();
    final BundleTemplateModel bundleModel = getBundleTemplateService().getBundleTemplateForCode(componentId,
            componentVersion);/*  w  ww  .j  a  va 2s .  com*/

    // bundle prices
    for (final ProductData productData : searchPageData.getResults()) {
        final ProductModel product = getProductService().getProductForCode(productData.getCode());
        final ChangeProductPriceBundleRuleModel priceRule = getBundleRuleService()
                .getChangePriceBundleRule(cartModel, bundleModel, product, bundleNo.intValue());
        SubscriptionPricePlanModel pricePlan = null;

        if (product instanceof SubscriptionProductModel) {
            pricePlan = getCommercePriceService()
                    .getSubscriptionPricePlanForProduct((SubscriptionProductModel) product);
        }

        final Double bestPrice = getMinPriceOfRuleAndPlan(pricePlan, priceRule);

        if (bestPrice != null) {
            final PriceData priceData = getPriceDataFactory().create(PriceDataType.BUY,
                    BigDecimal.valueOf(bestPrice.doubleValue()), cartModel.getCurrency().getIsocode());

            productData.setThisBundleProductPrice(priceData);
        }
    }

    // disable rules
    for (final ProductData productData : searchPageData.getResults()) {
        final ProductModel product = getProductService().getProductForCode(productData.getCode());
        final String disableMessage = getBundleCommerceCartService()
                .checkAndGetReasonForDisabledProductInComponent(cartModel, product, bundleModel,
                        bundleNo.intValue(), true);
        if (disableMessage != null) {
            productData.setDisabled(true);
            productData.setDisabledMessage(disableMessage);
        }
    }

    return searchPageData;
}

From source file:edu.cudenver.bios.power.OneSampleStudentsTPowerCalculator.java

/**
 * Calculate sample size for the one sample Student's T test
 *
 * @see OneSampleStudentsTPowerParameters
 * @see OneSampleStudentsTPower/*from   w w w.  ja v  a2  s .co m*/
 * @param params one sample student's t input parameters
 * @return list of power objects containing detectable difference results
 */
@Override
public List<Power> getSampleSize(PowerParameters params) {
    OneSampleStudentsTPowerParameters studentsTParams = (OneSampleStudentsTPowerParameters) params;

    ArrayList<Power> results = new ArrayList<Power>();

    // calculate the sample size for either one or two tails
    for (Double alpha : studentsTParams.getAlphaList()) {
        for (Double sigma : studentsTParams.getSigmaList()) {
            for (MeanPair means : studentsTParams.getMeansList()) {
                for (Double power : studentsTParams.getPowerList()) {
                    results.add(calculateSampleSize(alpha.doubleValue(), means.mu0, means.muA,
                            sigma.doubleValue(), power.doubleValue(), studentsTParams.isTwoTailed()));
                }
            }
        }
    }

    return results;
}

From source file:org.n52.ifgicopter.spf.input.HistoryPostgisInputPlugin.java

/**
 * @return//w  w w  . ja va 2s .  co m
 * 
 */
@Override
protected JPanel makeControlPanel() {
    if (this.controlPanel == null) {
        this.controlPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));

        JButton startButton = new JButton("Start");
        startButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        start();
                    }
                });
            }
        });
        this.controlPanel.add(startButton);
        JButton stopButton = new JButton("Stop");
        stopButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        stop();
                    }
                });
            }
        });
        this.controlPanel.add(stopButton);

        JLabel sleepTimeLabel = new JLabel("Time between points in seconds:");
        this.controlPanel.add(sleepTimeLabel);
        double spinnerMin = 0.1d;
        double spinnerMax = 10000.0d;
        SpinnerModel model = new SpinnerNumberModel(2.0d, spinnerMin, spinnerMax, 0.1d);
        JSpinner sleepTimeSpinner = new JSpinner(model);
        sleepTimeSpinner.setToolTipText("Select time using controls or manual input within the range of "
                + spinnerMin + " to " + spinnerMax + ".");
        sleepTimeSpinner.addChangeListener(new ChangeListener() {

            @Override
            public void stateChanged(ChangeEvent e) {
                Object source = e.getSource();
                if (source instanceof JSpinner) {
                    final JSpinner spinner = (JSpinner) source;

                    EventQueue.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            Double value = (Double) spinner.getValue();
                            value = Double.valueOf(value.doubleValue() * 1000d);
                            setSleepTimeMillis(value.longValue());
                        }
                    });
                } else
                    log.warn("Unsupported ChangeEvent, need JSpinner as source: " + e);
            }
        });
        // catch text change events without loosing the focus
        // JSpinner.DefaultEditor editor = (DefaultEditor) sleepTimeSpinner.getEditor();
        // not implemented, can be done using KeyEvent, but then it hast to be checked where in the text
        // field the keystroke was etc. --> too complicated.

        this.controlPanel.add(sleepTimeSpinner);

        JLabel whereLabel = new JLabel("Where clause: ");
        this.whereField = new JTextField(this.where);
        this.whereField.setPreferredSize(new Dimension(200, 20));
        this.whereField.setToolTipText("Insert a valid SQL 'WHERE' clause here.");
        this.whereButton = new JButton("Load data");
        this.whereButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        updateWhere();

                        loadAllData();
                    }
                });
            }
        });

        this.controlPanel.add(whereLabel);
        this.controlPanel.add(this.whereField);
        this.controlPanel.add(this.whereButton);
    }

    return this.controlPanel;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.boxcharts.BoxCharts.java

/**
 * Inherited by IChart: calculates chart value.
 * /*w ww .j av a 2  s.co  m*/
 * @return the dataset
 * 
 * @throws Exception the exception
 */

public DatasetMap calculateValue() throws Exception {
    logger.debug("IN");
    String res = DataSetAccessFunctions.getDataSetResultFromId(profile, getData(), parametersObject);
    categories = new HashMap();

    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    SourceBean sbRows = SourceBean.fromXMLString(res);
    List listAtts = sbRows.getAttributeAsList("ROW");

    // run all categories (one for each row)
    categoriesNumber = 0;

    boolean first = true;
    boolean first2 = true;

    double temp;

    for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) {
        SourceBean category = (SourceBean) iterator.next();
        List atts = category.getContainedAttributes();

        // atts are all the serie, run through them and sets what you need
        List values = new ArrayList();
        String nameP = "";
        String value = "";
        String catValue = "";

        if (first2) {
            if (name.indexOf("$F{") >= 0) {
                setTitleParameter(atts);
            }
            if (getSubName() != null && getSubName().indexOf("$F") >= 0) {
                setSubTitleParameter(atts);
            }
            first2 = false;
        }

        for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next();

            nameP = new String(object.getKey());
            value = new String((String) object.getValue());

            if (nameP.equalsIgnoreCase("x")) {
                catValue = value;
                categoriesNumber = categoriesNumber + 1;
                categories.put(new Integer(categoriesNumber), value);
            } else {
                Double valore = Double.valueOf(value);

                // set minimum e maximus to avoid auto range of axis
                if (first) {
                    min = valore.doubleValue();
                    max = valore.doubleValue();
                    first = false;
                }

                if (min > valore.doubleValue())
                    min = valore.doubleValue();
                if (max < valore.doubleValue())
                    max = valore.doubleValue();

                values.add(valore);

            }
        }
        dataset.add(values, "serie", catValue);
    }

    logger.debug("OUT");
    DatasetMap datasets = new DatasetMap();
    datasets.addDataset("1", dataset);
    return datasets;
}