Example usage for java.lang Integer doubleValue

List of usage examples for java.lang Integer doubleValue

Introduction

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

Prototype

public double doubleValue() 

Source Link

Document

Returns the value of this Integer as a double after a widening primitive conversion.

Usage

From source file:com.esri.ArcGISController.java

private Map<Long, Double> query(final String where, final double xmin, final double ymin, final double xmax,
        final double ymax, final Range range) {
    final Map<Long, Double> map = new HashMap<Long, Double>();

    final Cache cache = m_cacheManager.getCache(m_cacheName);

    final Attribute<Long> attrGeoHash = cache.getSearchAttribute("geohash");
    final Attribute<Double> attrX = cache.getSearchAttribute("x");
    final Attribute<Double> attrY = cache.getSearchAttribute("y");

    final Query query = cache.createQuery().includeAttribute(attrGeoHash).includeAggregator(Aggregators.count())
            .addCriteria(attrX.between(xmin - m_cell, xmax + m_cell))
            .addCriteria(attrY.between(ymin - m_cell, ymax + m_cell)).addGroupBy(attrGeoHash);

    addCriteria(cache, query, where);//from   www.j  ava2 s  .c o  m

    final Results results = query.execute();
    final List<Result> all = results.all();
    final int size = all.size();
    for (final Result result : all) {
        final long geoHash = result.getAttribute(attrGeoHash);
        final List aggregatorsList = result.getAggregatorResults();
        final Integer count = (Integer) aggregatorsList.get(0);
        final double v = count.doubleValue();
        if (v < range.lo) {
            range.lo = v;
        }
        if (v > range.hi) {
            range.hi = v;
        }
        map.put(geoHash, v);
    }

    m_log.info(String.format("size = %d lo = %.1f hi = %.1f", size, range.lo, range.hi));

    return map;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.ScatterCharts.java

/**
 * Inherited by IChart: calculates chart value.
 * //from w  w  w . ja v  a  2s. co m
 * @return the dataset
 * 
 * @throws Exception the exception
 */

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

    DefaultXYDataset dataset = new DefaultXYDataset();

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

    series = new Vector();

    boolean firstX = true;
    boolean firstY = true;
    double xTempMax = 0.0;
    double xTempMin = 0.0;
    double yTempMax = 0.0;
    double yTempMin = 0.0;
    boolean first = true;

    // In list atts there are all the series, let's run each
    for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) {
        SourceBean serie = (SourceBean) iterator.next();
        List atts = serie.getContainedAttributes();

        String catValue = "";
        String serValue = "";

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

        double[] x = new double[atts.size()];
        double[] y = new double[atts.size()];

        //List x=new ArrayList();
        //List y=new ArrayList();
        //ArrayList z=new ArrayList();

        String name = "";
        String value = "";

        //run all the attributes of the serie
        for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next();

            name = new String(object.getKey());
            value = (((String) object.getValue()).equals("null")) ? "0"
                    : new String((String) object.getValue());

            if (name.equalsIgnoreCase("x")) {
                catValue = value;

            }

            else if (String.valueOf(name.charAt(0)).equalsIgnoreCase("x")
                    || String.valueOf(name.charAt(0)).equalsIgnoreCase("y")) {
                String pos = String.valueOf(name.charAt(0));
                String numS = name.substring(1);
                int num = Integer.valueOf(numS).intValue();

                double valueD = 0.0;
                try {
                    valueD = (Double.valueOf(value)).doubleValue();
                } catch (NumberFormatException e) {
                    Integer intero = Integer.valueOf(value);
                    valueD = intero.doubleValue();

                }

                if (pos.equalsIgnoreCase("x")) {
                    x[num] = valueD;

                    if (firstX) {
                        xTempMin = valueD;
                        xTempMax = valueD;
                        firstX = false;
                    }
                    if (valueD < xTempMin)
                        xTempMin = valueD;
                    if (valueD > xTempMax)
                        xTempMax = valueD;

                } else if (pos.equalsIgnoreCase("y")) {
                    y[num] = valueD;

                    if (firstY) {
                        yTempMin = valueD;
                        yTempMax = valueD;
                        firstY = false;
                    }
                    if (valueD < yTempMin)
                        yTempMin = valueD;
                    if (valueD > yTempMax)
                        yTempMax = valueD;

                }
            }

        }

        xMin = xTempMin;
        xMax = xTempMax;

        yMin = yTempMin;
        yMax = yTempMax;

        double[][] seriesT = new double[][] { y, x };

        dataset.addSeries(catValue, seriesT);
        series.add(catValue);
        //add annotations on the chart if requested
        if (viewAnnotations != null && viewAnnotations.equalsIgnoreCase("true")) {
            annotationMap.put(catValue, seriesT);
        }

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

From source file:org.pentaho.reporting.engine.classic.core.modules.gui.base.actions.ZoomCustomActionPlugin.java

public boolean configure(final PreviewPane reportPane) {
    final Integer result = NumericInputDialog.showInputDialog(getContext().getWindow(),
            JOptionPane.QUESTION_MESSAGE, resources.getString("dialog.zoom.title"), //$NON-NLS-1$
            resources.getString("dialog.zoom.message"), //$NON-NLS-1$
            25, 400, (int) (reportPane.getZoom() * 100), false);

    if (result == null) {
        return false;
    }/*w w w. ja va2s  .com*/
    try {
        final double zoom = result.doubleValue();
        reportPane.setZoom(zoom / 100.0);
        return true;
    } catch (Exception ex) {
        ZoomCustomActionPlugin.logger
                .info(resources.getString("ZoomCustomActionPlugin.INFO_EXCEPTION_SWALLOWED")); //$NON-NLS-1$
    }
    return false;
}

From source file:hu.ppke.itk.nlpg.purepos.model.internal.HashSuffixGuesser.java

/**
 * Calculates the probability for a given suffix and tag.
 * // w  w w  .  j a  v a 2  s  . c  o m
 * @param word
 *            the word which has the suffix
 * @param index
 *            end position of the suffix (usually the length of the suffix)
 * @param tag
 *            POS tag
 * @return
 */
@Deprecated
protected double getTagProbTnT(String word, int index, T tag) {

    if (index >= 0 && freqTable.containsKey(word.substring(index))) {
        String suffix = word.substring(index);

        MutablePair<HashMap<T, Integer>, Integer> suffixValue = freqTable.get(suffix);
        Integer tagSufFreq = suffixValue.getLeft().get(tag);
        Double tagSufFreqD;
        int newindex = index - 1;
        if (tagSufFreq == null) {
            newindex = -1;
            tagSufFreqD = 0.0;
        } else {
            tagSufFreqD = tagSufFreq.doubleValue();
        }
        Double relFreq = tagSufFreqD / suffixValue.getRight();
        double nTagProb = getTagProbTnT(word, newindex, tag);

        return (theta * relFreq + nTagProb) / thetaPlusOne;
    } else
        return 0;
}

From source file:playground.artemc.analysis.AnalysisControlerListener.java

private void writeGraph(String name, String yLabel, Map<Integer, Double> it2Double) {

    XYLineChart chart = new XYLineChart(name, "Iteration", yLabel);

    double[] xValues = new double[it2Double.size()];
    double[] yValues = new double[it2Double.size()];
    int counter = 0;
    for (Integer iteration : it2Double.keySet()) {
        xValues[counter] = iteration.doubleValue();
        yValues[counter] = it2Double.get(iteration);
        counter++;/*from w  ww.j  a  v a  2 s  .  c o m*/
    }

    chart.addSeries(name, xValues, yValues);

    XYPlot plot = chart.getChart().getXYPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRange(true);
    axis.setAutoRangeIncludesZero(false);

    String outputFile = this.scenario.getConfig().controler().getOutputDirectory() + "/" + name + ".png";
    chart.saveAsPng(outputFile, 1000, 800); // File Export
}

From source file:playground.artemc.analysis.AnalysisControlerListener.java

private void writeGraphSum(String name, String yLabel, Map<Integer, Double> it2Double1,
        Map<Integer, Double> it2Double2) {

    XYLineChart chart = new XYLineChart(name, "Iteration", yLabel);

    double[] xValues = new double[it2Double1.size()];
    double[] yValues = new double[it2Double1.size()];
    int counter = 0;
    for (Integer iteration : it2Double1.keySet()) {
        xValues[counter] = iteration.doubleValue();
        yValues[counter] = (it2Double1.get(iteration)) + (it2Double2.get(iteration));
        counter++;/*from  w w  w  .  j  a v a2s.co m*/
    }

    chart.addSeries(name, xValues, yValues);

    XYPlot plot = chart.getChart().getXYPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRange(true);
    axis.setAutoRangeIncludesZero(false);

    String outputFile = this.scenario.getConfig().controler().getOutputDirectory() + "/" + name + ".png";
    chart.saveAsPng(outputFile, 1000, 800); // File Export
}

From source file:playground.artemc.analysis.AnalysisControlerListener.java

private void writeGraphDiv(String name, String yLabel, Map<Integer, Double> it2Double1,
        Map<Integer, Double> it2Double2) {

    XYLineChart chart = new XYLineChart(name, "Iteration", yLabel);

    double[] xValues = new double[it2Double1.size()];
    double[] yValues = new double[it2Double1.size()];
    int counter = 0;
    for (Integer iteration : it2Double1.keySet()) {
        xValues[counter] = iteration.doubleValue();
        yValues[counter] = (it2Double1.get(iteration)) / (it2Double2.get(iteration));
        counter++;/*from   w w  w.  j  ava2  s  .c  o m*/
    }

    chart.addSeries(name, xValues, yValues);

    XYPlot plot = chart.getChart().getXYPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRange(true);
    axis.setAutoRangeIncludesZero(false);

    String outputFile = this.scenario.getConfig().controler().getOutputDirectory() + "/" + name + ".png";
    chart.saveAsPng(outputFile, 1000, 800); // File Export
}

From source file:org.grails.datastore.mapping.model.types.BasicTypeConverterRegistrar.java

public void register(ConverterRegistry registry) {
    registry.addConverter(new Converter<Date, String>() {
        public String convert(Date date) {
            return String.valueOf(date.getTime());
        }/*from   ww w  . j a  v  a2s.  c  o m*/
    });

    registry.addConverter(new Converter<Date, Calendar>() {
        public Calendar convert(Date date) {
            final GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTime(date);
            return calendar;
        }
    });

    registry.addConverter(new Converter<Integer, Long>() {
        public Long convert(Integer integer) {
            return integer.longValue();
        }
    });

    registry.addConverter(new Converter<Long, Integer>() {
        public Integer convert(Long longValue) {
            return longValue.intValue();
        }
    });

    registry.addConverter(new Converter<Integer, Double>() {
        public Double convert(Integer integer) {
            return integer.doubleValue();
        }
    });

    registry.addConverter(new Converter<CharSequence, Date>() {
        public Date convert(CharSequence s) {
            try {
                final Long time = Long.valueOf(s.toString());
                return new Date(time);
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Double>() {
        public Double convert(CharSequence s) {
            try {
                return Double.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Integer>() {
        public Integer convert(CharSequence s) {
            try {
                return Integer.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<CharSequence, Long>() {
        public Long convert(CharSequence s) {
            try {
                return Long.valueOf(s.toString());
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });

    registry.addConverter(new Converter<Object, String>() {
        public String convert(Object o) {
            return o.toString();
        }
    });

    registry.addConverter(new Converter<Calendar, String>() {
        public String convert(Calendar calendar) {
            return String.valueOf(calendar.getTime().getTime());
        }
    });

    registry.addConverter(new Converter<CharSequence, Calendar>() {
        public Calendar convert(CharSequence s) {
            try {
                Date date = new Date(Long.valueOf(s.toString()));
                Calendar c = new GregorianCalendar();
                c.setTime(date);
                return c;
            } catch (NumberFormatException e) {
                throw new IllegalArgumentException(e);
            }
        }
    });
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.MarkerScatter.java

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

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

    DefaultXYDataset dataset = new DefaultXYDataset();

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

    series = new Vector();

    boolean firstX = true;
    boolean firstY = true;
    double xTempMax = 0.0;
    double xTempMin = 0.0;
    double yTempMax = 0.0;
    double yTempMin = 0.0;
    boolean first = true;

    // In list atts there are all the series, let's run each
    for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) {
        SourceBean serie = (SourceBean) iterator.next();
        List atts = serie.getContainedAttributes();

        String catValue = "";
        String serValue = "";

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

        //defines real dimension of attributes x1,y1,x2,y2...the number must be the same for x and y column
        int numAttsX = 0;
        int numAttsY = 0;

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

            String name = new String(object.getKey());
            if (!name.equalsIgnoreCase("x")) {
                if (String.valueOf(name.charAt(0)).equalsIgnoreCase("x"))
                    numAttsX++;
                else if (String.valueOf(name.charAt(0)).equalsIgnoreCase("y"))
                    numAttsY++;
            }
        }
        int maxNumAtts = (numAttsX < numAttsY) ? numAttsY : numAttsX;
        //double[] x=new double[atts.size()];
        //double[] y=new double[atts.size()];
        double[] x = new double[maxNumAtts];
        double[] y = new double[maxNumAtts];

        String name = "";
        String value = "";

        //run all the attributes of the serie
        for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next();

            name = new String(object.getKey());
            value = (((String) object.getValue()).equals("null")) ? "0"
                    : new String((String) object.getValue());

            if (name.equalsIgnoreCase("x")) {
                catValue = value;
            } else if (String.valueOf(name.charAt(0)).equalsIgnoreCase("x")
                    || String.valueOf(name.charAt(0)).equalsIgnoreCase("y")) {

                //String pos=name;
                String pos = String.valueOf(name.charAt(0));
                String numS = name.substring(1);
                int num = Integer.valueOf(numS).intValue();

                double valueD = 0.0;
                try {
                    valueD = (Double.valueOf(value)).doubleValue();
                } catch (NumberFormatException e) {
                    Integer intero = Integer.valueOf(value);
                    valueD = intero.doubleValue();

                }

                if (pos.equalsIgnoreCase("x")) {
                    //num++;
                    x[num] = valueD;

                    if (firstX) {
                        xTempMin = valueD;
                        xTempMax = valueD;
                        firstX = false;
                    }
                    if (valueD < xMin)
                        xMin = valueD;
                    if (valueD > xMax)
                        xMax = valueD;

                } else if (pos.equalsIgnoreCase("y")) {
                    y[num] = valueD;

                    if (firstY) {
                        yTempMin = valueD;
                        yTempMax = valueD;
                        firstY = false;
                    }
                    if (valueD < yMin)
                        yMin = valueD;
                    if (valueD > yMax)
                        yMax = valueD;
                }
            }
        }

        double[][] seriesT = new double[][] { y, x };

        dataset.addSeries(catValue, seriesT);
        series.add(catValue);
        //add annotations on the chart if requested
        if (viewAnnotations != null && viewAnnotations.equalsIgnoreCase("true")) {
            double tmpx = seriesT[1][0];
            double tmpy = seriesT[0][0];
            annotationMap.put(catValue, String.valueOf(tmpx) + "__" + String.valueOf(tmpy));
        }
    }
    logger.debug("OUT");
    DatasetMap datasets = new DatasetMap();
    datasets.addDataset("1", dataset);
    return datasets;
}

From source file:ubic.basecode.io.reader.HistogramReader.java

/**
 * @return//from ww  w  . j a v  a  2 s  . c  o  m
 * @throws IOException
 */
public Histogram1D read1D() throws IOException {
    int numHeaderLines = 1; // ignore the column header
    Map<Double, Integer> binCountMap = new HashMap<Double, Integer>();
    double min = Double.POSITIVE_INFINITY;
    double max = Double.NEGATIVE_INFINITY;
    while (in.ready()) {
        String line = in.readLine();
        if (StringUtils.isBlank(line))
            continue;
        if (line.startsWith("#") || numHeaderLines-- > 0)
            continue;
        String fields[] = line.split("\t");
        Double bin = Double.valueOf(fields[0]);
        Integer count = Integer.valueOf(fields[1]);
        binCountMap.put(bin, count);
        if (bin < min) {
            min = bin;
        } else if (bin > max) {
            max = bin;
        }
    }
    int numBins = binCountMap.keySet().size();

    Histogram1D hist = new Histogram1D(title, numBins, min, max);
    for (Entry<Double, Integer> element : binCountMap.entrySet()) {
        Entry<Double, Integer> entry = element;
        Double bin = entry.getKey();
        Integer count = entry.getValue();
        hist.fill(bin.doubleValue(), count.doubleValue());
    }
    return hist;
}