Example usage for java.lang Double Double

List of usage examples for java.lang Double Double

Introduction

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

Prototype

@Deprecated(since = "9")
public Double(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Double object that represents the floating-point value of type double represented by the string.

Usage

From source file:com.fileanalyzer.util.LineStatisticCalculator.java

public FileStatistic getFileStatistic() {
    FileStatistic fileStatis = new FileStatistic();

    fileStatis.setLengthLine(new Long(line.length()));
    String strArr[] = line.split(regexp);
    TreeSet<Integer> maxWord = new TreeSet();
    TreeSet<Integer> minWord = new TreeSet();
    long sumWords = 0;
    for (int i = 0; i < strArr.length; ++i) {
        int strSize = strArr[i].length();
        sumWords += strSize;/*from  w  ww .  ja v a2 s .com*/
        if (i > 0 && i < strArr.length - 1)
            maxWord.add(strSize);
        minWord.add(strSize);
    }
    fileStatis.setLine(HtmlUtils.htmlEscape(line));
    if (sumWords > 0) {
        fileStatis.setAvgWord(new Double(sumWords / strArr.length));
        fileStatis.setMinWord(new Long(minWord.first()));
    }
    if (maxWord.size() > 0)
        fileStatis.setMaxWord(new Long(maxWord.last()));
    if (getIdFk() != null)
        fileStatis.setFileId(getIdFk());
    return fileStatis;
}

From source file:apiserver.services.images.services.jhlabs.BumpFilterService.java

public Object doFilter(Message<?> message) throws MessageConfigException {
    BumpJob props = (BumpJob) message.getPayload();

    int edgeAction = props.getEdgeAction();
    boolean useAlpha = props.isUseAlpha();
    float[] embossMatrix = props.getMatrix();

    try {/*  w  w  w .j av  a2  s  .  com*/

        // calculate
        int rows = new Double(Math.sqrt(new Integer(embossMatrix.length).doubleValue())).intValue();
        int cols = new Double(Math.sqrt(new Integer(embossMatrix.length).doubleValue())).intValue();

        //run filter
        BumpFilter filter = new BumpFilter();
        filter.setEdgeAction(edgeAction);
        filter.setUseAlpha(useAlpha);
        filter.setKernel(new Kernel(rows, cols, embossMatrix));

        BufferedImage bufferedImage = props.getBufferedImage();
        if (bufferedImage == null) {
            throw new MessageConfigException(MessageConfigException.MISSING_PROPERTY);
        }

        BufferedImage outFile = filter.filter(bufferedImage, null);

        props.setBufferedImage(outFile);
        return message;
    } catch (Throwable e) {
        //log.error(e.getMessage(), e);
        throw new RuntimeException(e);
    }
}

From source file:edu.umd.umiacs.clip.tools.classifier.LibSVMUtils.java

public static Map<Integer, Double> asMap(String features) {
    if (features.isEmpty()) {
        return new HashMap<>();
    }/*from  w  w w.  j a  v  a 2 s.  c  o  m*/
    return Stream.of(features.trim().split("\\s+")).map(p -> p.split(":"))
            .collect(toMap(p -> new Integer(p[0]), p -> new Double(p[1])));
}

From source file:net.sf.jasperreports.samples.jfreechart.JFreeChartScriptlet.java

/**
 *
 *//*from   ww  w  .j av a  2 s.  c om*/
public void afterReportInit() throws JRScriptletException {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Java", new Double(43.2));
    dataset.setValue("Visual Basic", new Double(10.0));
    dataset.setValue("C/C++", new Double(17.5));
    dataset.setValue("PHP", new Double(32.5));
    dataset.setValue("Perl", new Double(1.0));

    JFreeChart chart = ChartFactory.createPieChart3D("Pie Chart 3D Demo 1", dataset, true, true, false);

    PiePlot3D plot = (PiePlot3D) chart.getPlot();
    plot.setStartAngle(290);
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    plot.setNoDataMessage("No data to display");

    /*   */
    this.setVariableValue("Chart", new JCommonDrawableRenderer(chart));
}

From source file:Main.java

/**
 * Return the real number represented by the String s,
 * or return Double.NaN if s does not represent a legal
 * real number./*from  ww  w.j  ava 2 s .c  om*/
 */
public static double stringToReal(String s) {
    try {
        Double d = new Double(s);
        return d.doubleValue();
    } catch (NumberFormatException e) {
        return Double.NaN;
    }
}

From source file:com.webpagebytes.cms.DefaultImageProcessor.java

private static Dimension<Integer> getResizeSize(int X, int Y, int desiredSize) {
    if (desiredSize <= 0 || X <= 0 || Y <= 0) {
        return new Dimension<Integer>(X, Y);
    }// ww  w . j  a  v a 2 s. c om
    double ratio = X / (double) Y;
    if (X > Y) {
        return new Dimension<Integer>(desiredSize, new Double(desiredSize / ratio).intValue());
    } else {
        return new Dimension<Integer>(new Double(desiredSize * ratio).intValue(), desiredSize);
    }
}

From source file:com.twosigma.beakerx.kernel.magic.command.functionality.MvnLoggerWidget.java

public MvnLoggerWidget(Message parentMessage) {
    this.widget = new BxHTML(parentMessage);
    this.timer = new Timer();
    this.timer.scheduleAtFixedRate(new TimerTask() {
        @Override//from w  w w . j  a va 2 s  . c o m
        public void run() {
            if (jarNumbers > 0) {
                String info = getInfo(currentLine);
                String sizeWithUnit = byteCountToDisplaySize(new Double(sizeInKb * 1000).longValue());
                String status = String.format("%d jar%s, %s downloaded at %s %s", jarNumbers,
                        getPluralFormWhenNumberOfJarGreaterThanOne(), sizeWithUnit, speed, info);
                widget.setValue(status + "</br>" + formatCurrentLine());
                widget.setDomClasses(asList("text-ellipsis"));
            }
        }
    }, 0, PERIOD);
}

From source file:edu.uci.ics.jung.algorithms.scoring.TestVoltageScore.java

@SuppressWarnings("unchecked")
public final void testCalculateVoltagesSourcesTargets() {
    Map<Number, Number> sources = new HashMap<Number, Number>();
    sources.put(0, new Double(1.0));
    sources.put(1, new Double(0.5));
    Set<Number> sinks = new HashSet<Number>();
    sinks.add(6);/* w w w .  j  a  v  a2s  .com*/
    sinks.add(5);
    VoltageScorer<Number, Number> vr = new VoltageScorer<Number, Number>(g, new ConstantTransformer(1), sources,
            sinks);
    double[] voltages = { 1.0, 0.5, 0.66, 0.33, 0.16, 0, 0 };

    vr.evaluate();
    for (int i = 0; i < 7; i++) {
        assertEquals(vr.getVertexScore(i), voltages[i], 0.01);
    }
}

From source file:Main.java

/**
 * Returns the value of a named node attribute in the form of an int
 * @param node The node to retrieve the attribute from
 * @param name The name of the attribute
 * @param defaultValue The default value if the attribute cannot be located or converted.
 * @return an int// w w w  .j a v a  2s  .  c  o  m
 */
public static int getAttributeByName(Node node, String name, int defaultValue) {
    if (node == null || name == null)
        return defaultValue;
    try {
        return new Double(getAttributeValueByName(node, name).trim()).intValue();
    } catch (Exception e) {
        return defaultValue;
    }
}

From source file:com.datamyne.charts.FinallyDemo.java

/**
 * Gets a {@link JFreeChart}./*from  w  w  w. ja v  a  2s  .c  om*/
 * @return {@link JFreeChart}.
 */
public JFreeChart getChart() {
    //create dummy data
    //take from http://www.java2s.com/Code/Java/Chart/JFreeChartPieChartDemo1.htm
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("One", new Double(43.2));
    dataset.setValue("Two", new Double(10.0));
    dataset.setValue("Three", new Double(27.5));
    dataset.setValue("Four", new Double(17.5));
    dataset.setValue("Five", new Double(11.0));
    dataset.setValue("Six", new Double(19.4));

    //use the ChartFactory to create a pie chart
    JFreeChart chart = ChartFactory.createPieChart("Dummy Data", dataset, true, true, false);
    return chart;
}