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.yccheok.jstock.gui.SellPortfolioChartJDialog.java

private JFreeChart createChart(String name) {
    final JStockOptions jStockOptions = JStock.instance().getJStockOptions();
    final boolean isFeeCalculationEnabled = jStockOptions.isFeeCalculationEnabled();

    final Portfolio portfolio = (Portfolio) portfolioTreeTableModel.getRoot();
    final int count = portfolio.getChildCount();
    DefaultPieDataset data = new DefaultPieDataset();
    final List<DataEx> dataExs = new ArrayList<>();

    for (int i = 0; i < count; i++) {
        TransactionSummary transactionSummary = (TransactionSummary) portfolio.getChildAt(i);

        if (transactionSummary.getChildCount() <= 0) {
            continue;
        }/*from w w  w.j a  v a 2s.  com*/

        Transaction transaction = (Transaction) transactionSummary.getChildAt(0);
        final Symbol symbol = transaction.getStock().symbol;
        final Code code = transaction.getStock().code;

        final boolean shouldConvertPenceToPound = org.yccheok.jstock.portfolio.Utils
                .shouldConvertPenceToPound(portfolioRealTimeInfo, code);

        /* Should use reflection technology. */
        if (name.equals(cNames[0])) {
            if (shouldConvertPenceToPound == false) {
                if (isFeeCalculationEnabled) {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            portfolioTreeTableModel.getNetGainLossValue(transactionSummary)));
                } else {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            portfolioTreeTableModel.getGainLossValue(transactionSummary)));
                }
            } else {
                if (isFeeCalculationEnabled) {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            portfolioTreeTableModel.getNetGainLossValue(transactionSummary) / 100.0));
                } else {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            portfolioTreeTableModel.getGainLossValue(transactionSummary) / 100.0));
                }
            }
        } else if (name.equals(cNames[1])) {
            if (shouldConvertPenceToPound == false) {
                if (isFeeCalculationEnabled) {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            -portfolioTreeTableModel.getNetGainLossValue(transactionSummary)));
                } else {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            -portfolioTreeTableModel.getGainLossValue(transactionSummary)));
                }
            } else {
                if (isFeeCalculationEnabled) {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            -portfolioTreeTableModel.getNetGainLossValue(transactionSummary) / 100.0));
                } else {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            -portfolioTreeTableModel.getGainLossValue(transactionSummary) / 100.0));
                }
            }
        } else if (name.equals(cNames[2])) {
            if (isFeeCalculationEnabled) {
                dataExs.add(DataEx.newInstance(symbol.toString(),
                        portfolioTreeTableModel.getNetGainLossPercentage(transactionSummary)));
            } else {
                dataExs.add(DataEx.newInstance(symbol.toString(),
                        portfolioTreeTableModel.getGainLossPercentage(transactionSummary)));
            }
        } else if (name.equals(cNames[3])) {
            if (isFeeCalculationEnabled) {
                dataExs.add(DataEx.newInstance(symbol.toString(),
                        -portfolioTreeTableModel.getNetGainLossPercentage(transactionSummary)));
            } else {
                dataExs.add(DataEx.newInstance(symbol.toString(),
                        -portfolioTreeTableModel.getGainLossPercentage(transactionSummary)));
            }
        } else if (name.equals(cNames[4])) {
            Double value = this.codeToTotalDividend.get(code);
            if (value != null) {
                if (value.doubleValue() > 0.0) {
                    dataExs.add(DataEx.newInstance(symbol.toString(), this.codeToTotalDividend.get(code)));
                }
            }
        } else if (name.equals(cNames[5])) {
            if (shouldConvertPenceToPound == false) {
                if (isFeeCalculationEnabled) {
                    dataExs.add(DataEx.newInstance(symbol.toString(), transactionSummary.getNetTotal()));
                } else {
                    dataExs.add(DataEx.newInstance(symbol.toString(), transactionSummary.getTotal()));
                }
            } else {
                if (isFeeCalculationEnabled) {
                    dataExs.add(
                            DataEx.newInstance(symbol.toString(), transactionSummary.getNetTotal() / 100.0));
                } else {
                    dataExs.add(DataEx.newInstance(symbol.toString(), transactionSummary.getTotal() / 100.0));
                }
            }
        } else if (name.equals(cNames[6])) {
            if (shouldConvertPenceToPound == false) {
                if (isFeeCalculationEnabled) {
                    dataExs.add(
                            DataEx.newInstance(symbol.toString(), transactionSummary.getNetReferenceTotal()));
                } else {
                    dataExs.add(DataEx.newInstance(symbol.toString(), transactionSummary.getReferenceTotal()));
                }
            } else {
                if (isFeeCalculationEnabled) {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            transactionSummary.getNetReferenceTotal() / 100.0));
                } else {
                    dataExs.add(DataEx.newInstance(symbol.toString(),
                            transactionSummary.getReferenceTotal() / 100.0));
                }
            }
        } else if (name.equals(cNames[7])) {
            dataExs.add(DataEx.newInstance(symbol.toString(), transactionSummary.getQuantity()));
        } else if (name.equals(cNames[8])) {
            dataExs.add(DataEx.newInstance(symbol.toString(), transactionSummary.getBroker()));
        } else if (name.equals(cNames[9])) {
            dataExs.add(DataEx.newInstance(symbol.toString(), transactionSummary.getStampDuty()));
        } else if (name.equals(cNames[10])) {
            dataExs.add(DataEx.newInstance(symbol.toString(), transactionSummary.getClearingFee()));
        }
    }

    Collections.sort(dataExs);

    for (DataEx dataEx : dataExs) {
        // Selling value can be negative sometimes.
        if (dataEx.value <= 0) {
            continue;
        }

        data.setValue(dataEx.data, dataEx.value);
    }

    // create a chart...
    return ChartFactory.createPieChart(name, data, true, true, true);
}

From source file:com.juick.android.TagsFragment.java

private void reloadTags(final View view) {
    final View selectedContainer = myView.findViewById(R.id.selected_container);
    final View progressAll = myView.findViewById(R.id.progress_all);
    Thread thr = new Thread(new Runnable() {

        public void run() {
            Bundle args = getArguments();
            MicroBlog microBlog;/* w w  w .java 2s.c o  m*/
            JSONArray json = null;
            final int tagsUID = showMine ? uid : 0;
            if (PointMessageID.CODE.equals(args.getString("microblog"))) {
                microBlog = MainActivity.microBlogs.get(PointMessageID.CODE);
                json = ((PointMicroBlog) microBlog).getUserTags(view, uidS);
            } else {
                microBlog = MainActivity.microBlogs.get(JuickMessageID.CODE);
                json = ((JuickMicroBlog) microBlog).getUserTags(view, tagsUID);
            }
            if (isAdded()) {
                final SpannableStringBuilder tagsSSB = new SpannableStringBuilder();
                if (json != null) {
                    try {
                        int cnt = json.length();
                        ArrayList<TagSort> sortables = new ArrayList<TagSort>();
                        for (int i = 0; i < cnt; i++) {
                            final String tagg = json.getJSONObject(i).getString("tag");
                            final int messages = json.getJSONObject(i).getInt("messages");
                            sortables.add(new TagSort(tagg, messages));
                        }
                        Collections.sort(sortables);
                        HashMap<String, Double> scales = new HashMap<String, Double>();
                        for (int sz = 0, sortablesSize = sortables.size(); sz < sortablesSize; sz++) {
                            TagSort sortable = sortables.get(sz);
                            if (sz < 10) {
                                scales.put(sortable.tag, 2.0);
                            } else if (sz < 20) {
                                scales.put(sortable.tag, 1.5);
                            }
                        }
                        int start = 0;
                        if (microBlog instanceof JuickMicroBlog
                                && getArguments().containsKey("add_system_tags")) {
                            start = -4;
                        }
                        for (int i = start; i < cnt; i++) {
                            final String tagg;
                            switch (i) {
                            case -4:
                                tagg = "public";
                                break;
                            case -3:
                                tagg = "friends";
                                break;
                            case -2:
                                tagg = "notwitter";
                                break;
                            case -1:
                                tagg = "readonly";
                                break;
                            default:
                                tagg = json.getJSONObject(i).getString("tag");
                                break;

                            }
                            int index = tagsSSB.length();
                            tagsSSB.append("*" + tagg);
                            tagsSSB.setSpan(new URLSpan(tagg) {
                                @Override
                                public void onClick(View widget) {
                                    onTagClick(tagg, tagsUID);
                                }
                            }, index, tagsSSB.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                            Double scale = scales.get(tagg);
                            if (scale != null) {
                                tagsSSB.setSpan(new RelativeSizeSpan((float) scale.doubleValue()), index,
                                        tagsSSB.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                            }
                            tagOffsets.put(tagg, new TagOffsets(index, tagsSSB.length()));
                            tagsSSB.append(" ");

                        }
                    } catch (Exception ex) {
                        tagsSSB.append("Error: " + ex.toString());
                    }
                }
                if (getActivity() != null) {
                    // maybe already closed?
                    getActivity().runOnUiThread(new Runnable() {

                        public void run() {
                            TextView tv = (TextView) myView.findViewById(R.id.tags);
                            progressAll.setVisibility(View.GONE);
                            if (multi)
                                selectedContainer.setVisibility(View.VISIBLE);
                            tv.setText(tagsSSB, TextView.BufferType.SPANNABLE);
                            tv.setMovementMethod(LinkMovementMethod.getInstance());
                            MainActivity.restyleChildrenOrWidget(view);
                            final TextView selected = (TextView) myView.findViewById(R.id.selected);
                            selected.setVisibility(View.VISIBLE);
                        }
                    });
                }
            }
        }
    });
    thr.start();
}

From source file:net.sourceforge.eclipsetrader.core.CurrencyConverter.java

public Double getExchangeRatio(String from, String to) {
    Double ratio = (Double) map.get(from + to);
    if (ratio == null) {
        Double r = (Double) map.get(to + from);
        if (r != null)
            ratio = new Double(1 / r.doubleValue());
    }//from   w ww . ja va 2s . co m
    return ratio;
}

From source file:com.opensymphony.module.propertyset.database.JDBCPropertySet.java

private void setValues(PreparedStatement ps, int type, String key, Object value)
        throws SQLException, PropertyException {
    // Patched by Edson Richter for MS SQL Server JDBC Support!
    String driverName;//from  ww  w  .j a va 2s . c om

    try {
        driverName = ps.getConnection().getMetaData().getDriverName().toUpperCase();
    } catch (Exception e) {
        driverName = "";
    }

    ps.setNull(1, Types.VARCHAR);
    ps.setNull(2, Types.TIMESTAMP);

    // Patched by Edson Richter for MS SQL Server JDBC Support!
    // Oracle support suggestion also Michael G. Slack
    if ((driverName.indexOf("SQLSERVER") >= 0) || (driverName.indexOf("ORACLE") >= 0)) {
        ps.setNull(3, Types.BINARY);
    } else {
        ps.setNull(3, Types.BLOB);
    }

    ps.setNull(4, Types.FLOAT);
    ps.setNull(5, Types.NUMERIC);
    ps.setInt(6, type);
    ps.setString(7, globalKey);
    ps.setString(8, key);

    switch (type) {
    case PropertySet.BOOLEAN:

        Boolean boolVal = (Boolean) value;
        ps.setInt(5, boolVal.booleanValue() ? 1 : 0);

        break;

    case PropertySet.DATA:

        Data data = (Data) value;
        ps.setBytes(3, data.getBytes());

        break;

    case PropertySet.DATE:

        Date date = (Date) value;
        ps.setTimestamp(2, new Timestamp(date.getTime()));

        break;

    case PropertySet.DOUBLE:

        Double d = (Double) value;
        ps.setDouble(4, d.doubleValue());

        break;

    case PropertySet.INT:

        Integer i = (Integer) value;
        ps.setInt(5, i.intValue());

        break;

    case PropertySet.LONG:

        Long l = (Long) value;
        ps.setLong(5, l.longValue());

        break;

    case PropertySet.STRING:
        ps.setString(1, (String) value);

        break;

    default:
        throw new PropertyException("This type isn't supported!");
    }
}

From source file:com.shishicai.app.utils.XmlToJson.java

private void putContent(String path, JSONObject json, String tag, String content) {
    try {//from w w w . ja v  a2 s  .  c  o  m
        if (content != null) {
            if (mForceStringForPath.contains(path)) {
                json.put(tag, content);
            }
            if (content.equalsIgnoreCase("true")) {
                json.put(tag, true);
            } else if (content.equalsIgnoreCase("false")) {
                json.put(tag, false);
            } else {
                try {
                    Integer integer = Integer.parseInt(content);
                    json.put(tag, integer);
                } catch (NumberFormatException exceptionInt) {
                    try {
                        Double number = Double.parseDouble(content);
                        json.put(tag, number.doubleValue());
                    } catch (NumberFormatException exceptionDouble) {
                        json.put(tag, content);
                    }
                }
            }
        }
    } catch (JSONException exception) {
    }
}

From source file:org.hyperic.hq.plugin.mysql_stats.MySqlStatsMeasurementPlugin.java

private double getTableMetric(Metric metric)
        throws NumberFormatException, SQLException, JDBCQueryCacheException {
    final String table = metric.getObjectProperty("table");
    final String dbname = metric.getObjectProperty("database");
    final String jdbcUrl = metric.getObjectProperty(PROP_URL);
    final String cacheKey = jdbcUrl + "-" + table;
    String alias = metric.getAttributeName();
    JDBCQueryCache tableCache = (JDBCQueryCache) _tableStatusCacheMap.get(cacheKey);
    // don't want to cache all of "show table status" in the case
    // we have a deployment with 1000s of tables.  They probably don't care
    // about all the tables.  There is still a speed/efficiency improvement
    // over the old mysql plugin since the query only has to be run once for
    // all the individual table metrics.
    if (tableCache == null) {
        final String sql = new StringBuffer().append("SELECT * FROM information_schema.tables")
                .append(" WHERE lower(table_name) = '").append(table.toLowerCase()).append('\'')
                .append(" AND lower(table_schema) = '").append(dbname.toLowerCase()).append('\'')
                .append(" AND engine is not null").toString();
        tableCache = new JDBCQueryCache(sql, "table_name", CACHE_TIMEOUT);
        _tableStatusCacheMap.put(cacheKey, tableCache);
    }//from  w  w  w  .j  a  v  a2 s. com
    if (metric.isAvail()) {
        alias = "TABLE_ROWS";
    }
    Connection conn = getCachedConnection(metric);
    Object cachedVal = null;
    cachedVal = tableCache.get(conn, table, alias);
    if (cachedVal == null) {
        if (metric.isAvail()) {
            return Metric.AVAIL_DOWN;
        } else {
            final String msg = "Could not get metric for table " + table;
            throw new SQLException(msg);
        }
    }
    Double val = Double.valueOf(cachedVal.toString());
    if (metric.isAvail()) {
        return Metric.AVAIL_UP;
    }
    return val.doubleValue();
}

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

private ArrayList<Double> getSplitpoints(LinkedList<double[]> startPartition, Attribute label) {
    LinkedList<LinkedList<double[]>> border = new LinkedList<LinkedList<double[]>>();
    ArrayList<Double> result = new ArrayList<Double>();
    border.addLast(startPartition);/* w  w  w.j ava 2 s .c  om*/
    while (!border.isEmpty()) {
        LinkedList<double[]> currentPartition = border.removeFirst();
        Double splitpoint = this.getMinEntropySplitpoint(currentPartition, label);
        if (splitpoint != null) {
            result.add(splitpoint);
            double splitValue = splitpoint.doubleValue();
            LinkedList<double[]> newPartition1 = new LinkedList<double[]>();
            LinkedList<double[]> newPartition2 = new LinkedList<double[]>();
            Iterator<double[]> it = currentPartition.iterator();
            while (it.hasNext()) { // Create new partitions.
                double[] attributeLabelPair = it.next();
                if (attributeLabelPair[0] <= splitValue) {
                    newPartition1.addLast(attributeLabelPair);
                } else {
                    newPartition2.addLast(attributeLabelPair);
                }
            }
            border.addLast(newPartition1);
            border.addLast(newPartition2);
        }
    }
    return result; // Empty ArrayList if no Splitpoint could be found.

}

From source file:chibi.gemmaanalysis.ExperimentMetaDataExtractorCli.java

public Collection<BatchEffectDetails> getBatchEffect(ExpressionExperiment ee, int maxcomp) {
    Collection<BatchEffectDetails> ret = new ArrayList<>();

    for (ExperimentalFactor ef : ee.getExperimentalDesign().getExperimentalFactors()) {
        if (BatchInfoPopulationServiceImpl.isBatchFactor(ef)) {
            SVDValueObject svd = svdService.getSvdFactorAnalysis(ee.getId());
            if (svd == null)
                break;

            for (Integer component : svd.getFactorPvals().keySet()) {
                if (component.intValue() >= maxcomp) {
                    break;
                }/* w ww  .  jav a  2  s .c  o  m*/
                Map<Long, Double> cmpEffects = svd.getFactorPvals().get(component);

                Double pval = cmpEffects.get(ef.getId());
                if (pval != null) {
                    BatchEffectDetails details = new BatchEffectDetails();
                    details.setPvalue(pval.doubleValue());
                    details.setComponent(new Integer(component.intValue() + 1));
                    details.setComponentVarianceProportion(
                            svd.getVariances()[component.intValue()].doubleValue());
                    details.setHasBatchInformation(true);
                    ret.add(details);
                }

            }
        }
    }
    return ret;
}

From source file:net.sourceforge.eclipsetrader.core.CurrencyConverter.java

public double convert(Double amount, Currency from, Currency to) {
    if (from == null || to == null || from.equals(to))
        return amount.doubleValue();
    return convert(null, amount.doubleValue(), from.getCurrencyCode(), to.getCurrencyCode());
}

From source file:net.sourceforge.eclipsetrader.core.CurrencyConverter.java

public double convert(Date date, Double amount, Currency from, Currency to) {
    if (from == null || to == null || from.equals(to))
        return amount.doubleValue();
    return convert(date, amount.doubleValue(), from.getCurrencyCode(), to.getCurrencyCode());
}