Example usage for java.lang Double toString

List of usage examples for java.lang Double toString

Introduction

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

Prototype

public static String toString(double d) 

Source Link

Document

Returns a string representation of the double argument.

Usage

From source file:com.igormaznitsa.jhexed.renders.svg.SVGImage.java

private static GraphicsNode loadDiagramFromStream(final InputStream in, final Dimension2D docSize)
        throws IOException {
    final String parser = XMLResourceDescriptor.getXMLParserClassName();
    final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
    final SVGDocument doc = factory.createSVGDocument("http://www.igormaznitsa.com/jhexed/svg", in);

    String strDocWidth = doc.getRootElement().getAttribute("width");
    String strDocHeight = doc.getRootElement().getAttribute("height");

    final GVTBuilder bldr = new GVTBuilder();

    final UserAgent userAgent = new UserAgentAdapter();
    final DocumentLoader loader = new DocumentLoader(userAgent);
    final BridgeContext ctx = new BridgeContext(userAgent, loader);

    final GraphicsNode result = bldr.build(ctx, doc);

    strDocWidth = strDocWidth.isEmpty() ? Double.toString(result.getSensitiveBounds().getWidth()) : strDocWidth;
    strDocHeight = strDocHeight.isEmpty() ? Double.toString(result.getSensitiveBounds().getHeight())
            : strDocHeight;//from  w w  w. j  a va2  s . c o  m

    docSize.setSize(Double.parseDouble(strDocWidth.trim()), Double.parseDouble(strDocHeight.trim()));

    return result;
}

From source file:com.intuit.tank.harness.functions.JexlNumericFunctions.java

/**
 * Adds all values together/*from  w ww .ja  va2 s  .  co m*/
 * 
 * @param values
 * @return summation
 */
public String add(Object... values) {
    double result = 0;
    for (int i = 0; i < values.length; i++) {
        result += FunctionHandler.getDouble(values[i]);
    }
    return Double.toString(result);
}

From source file:io.cloudex.cloud.impl.google.storage.DownloadProgressListener.java

@Override
public void progressChanged(MediaHttpDownloader downloader) {
    switch (downloader.getDownloadState()) {
    case MEDIA_IN_PROGRESS:
        log.info("Progress: " + Double.toString(Math.round(downloader.getProgress() * 100.00)));
        break;//from  w w w .  j  av  a 2 s  .  com
    case MEDIA_COMPLETE:
        if (stopwatch.isRunning()) {
            stopwatch.stop();
        }
        log.info(String.format("Download is complete! (%s)", stopwatch));
        if (this.callback != null) {
            this.callback.execute();
        }
        break;
    case NOT_STARTED:
        break;
    }
}

From source file:Counter.java

public void countWords() {
    try {/*  ww w  .j av  a  2 s . c o m*/
        while (st.nextToken() != StreamTokenizer.TT_EOF) {
            String s;
            switch (st.ttype) {
            case StreamTokenizer.TT_EOL:
                s = new String("EOL");
                break;
            case StreamTokenizer.TT_NUMBER:
                s = Double.toString(st.nval);
                break;
            case StreamTokenizer.TT_WORD:
                s = st.sval; // Already a String
                break;
            default: // single character in ttype
                s = String.valueOf((char) st.ttype);
            }
            if (counts.containsKey(s))
                ((Counter) counts.get(s)).increment();
            else
                counts.put(s, new Counter());
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:blue.soundObject.jmask.Constant.java

public Element saveAsXML() {
    Element retVal = new Element("generator");
    retVal.setAttribute("type", getClass().getName());

    retVal.addElement("value").setText(Double.toString(value));

    return retVal;
}

From source file:com.norconex.commons.wicket.markup.html.chart.jqplot.Point.java

private String convert(Object obj) {
    if (obj == null) {
        return "''";
    }//from   w  w w.ja  v  a2 s.  c  om
    if (Integer.class.isAssignableFrom(obj.getClass())) {
        return Integer.toString((Integer) obj);
    }
    if (Float.class.isAssignableFrom(obj.getClass())) {
        return Float.toString((Float) obj);
    }
    if (Long.class.isAssignableFrom(obj.getClass())) {
        return Long.toString((Long) obj);
    }
    if (Double.class.isAssignableFrom(obj.getClass())) {
        return Double.toString((Double) obj);
    }
    return "'" + StringUtils.replace(obj.toString(), "'", "\\'") + "'";
}

From source file:blue.soundObject.jmask.TablePoint.java

public Element saveAsXML() {
    Element retVal = new Element("point");

    retVal.setAttribute("time", Double.toString(getTime()));
    retVal.setAttribute("value", Double.toString(getValue()));

    return retVal;
}

From source file:com.cloudera.oryx.app.batch.mllib.rdf.RandomCategoricalRDFDataGenerator.java

@Override
public Pair<String, String> generate(int id, RandomGenerator random) {
    List<String> elements = new ArrayList<>(n + 2);
    elements.add(Integer.toString(id));
    boolean positive = true;
    for (int i = 0; i < n; i++) {
        double d = random.nextDouble();
        if (d < 0.5) {
            positive = false;//from w  w  w.  j av  a 2  s  .c om
        }
        elements.add(Double.toString(d));
    }
    elements.add(Boolean.toString(positive));
    return new Pair<>(Integer.toString(id), TextUtils.joinDelimited(elements, ','));
}

From source file:net.dnsviz.lookingglass.DNSLookingGlass.java

protected DNSQueryTransportHandler[] getDNSQueryTransportHandlers(JSONObject obj)
        throws JSONException, UnknownHostException {
    DNSQueryTransportHandler[] ret;//from   w  w w .ja  v  a 2 s.  co m
    JSONArray requests;
    String[] vers;
    String src;
    int sport;
    JSONObject reqObj;

    vers = Double.toString(obj.getDouble("version")).split("\\.");
    if (Integer.parseInt(vers[0]) != 1 || Integer.parseInt(vers[1]) > 0) {
        throw new JSONException("Version of JSON input is invalid");
    }

    requests = obj.getJSONArray("requests");
    ret = new DNSQueryTransportHandler[requests.length()];
    for (int i = 0; i < requests.length(); i++) {
        reqObj = requests.getJSONObject(i);
        if (reqObj.has("src")) {
            src = reqObj.getString("src");
        } else {
            src = null;
        }
        if (reqObj.has("sport")) {
            sport = reqObj.getInt("sport");
        } else {
            sport = 0;
        }
        ret[i] = getDNSQueryTransportHandler(reqObj.getString("req"), reqObj.getString("dst"),
                reqObj.getInt("dport"), src, sport, reqObj.getLong("timeout"), reqObj.getBoolean("tcp"));
    }
    return ret;
}

From source file:gov.nih.nci.calims2.business.administration.unit.JConvertAdapter.java

/**
 * {@inheritDoc}// ww  w .ja va  2 s .c  o m
 */
public Quantity convert(Quantity from, StandardUnit toUnit) {
    checkInputs(from, toUnit);
    ConversionTypeData conversionTypeData = getConversionTypeData(from.getStandardUnit().getType());
    String fromUnitId = from.getStandardUnit().getId().toString();
    String toUnitId = toUnit.getId().toString();
    double value = conversionTypeData.convert(from.getValue(), fromUnitId, toUnitId);
    Quantity result = new Quantity();
    result.setStandardUnit(toUnit);
    result.setType(from.getType());
    result.setValue(Double.toString(value));
    return result;
}