Example usage for java.lang Long doubleValue

List of usage examples for java.lang Long doubleValue

Introduction

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

Prototype

public double doubleValue() 

Source Link

Document

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

Usage

From source file:org.finra.dm.dao.impl.S3DaoImpl.java

/**
 * Returns transfer rate in Mbit/s (Decimal prefix: 1 Mbit/s =  1,000,000 bit/s).
 *
 * @param totalBytesTransferred Number of bytes transferred.
 * @param durationMillis Duration in milliseconds.
 *
 * @return the transfer rate in Mbit/s.// w w w  . ja va2s. com
 */
private Double getTransferRateInMegabitsPerSecond(Long totalBytesTransferred, Long durationMillis) {
    return totalBytesTransferred.doubleValue() * BITS_PER_BYTE / durationMillis / 1000;
}

From source file:org.kalypso.ogc.sensor.diagview.jfreechart.ObservationPlot.java

private void analyseCurve(final DiagViewCurve curve) throws SensorException {
    final IObservation obs = curve.getObservation();

    if (curve.getView().isFeatureEnabled(ITimeseriesConstants.FEATURE_FORECAST)) {
        // add a marker if the obs is a forecast
        final DateRange fr = TimeseriesUtils.isTargetForecast(obs);
        if (fr != null) {
            final Long begin = new Long(fr.getFrom().getTime());
            if (!m_markers.containsKey(begin)) {
                final long end = fr.getTo().getTime();
                final Marker marker = createMarker(begin.doubleValue(), end,
                        Messages.getString("ObservationPlot.0"), //$NON-NLS-1$
                        TimeseriesUtils.getColorForMD(ITimeseriesConstants.MD_VORHERSAGE));

                addDomainMarker(marker, Layer.BACKGROUND);

                m_markers.put(begin, marker);
            }/*from   ww w . j  ava 2 s  . c om*/
        }
    }

    if (obs != null) {
        // add a constant Y line if obs has alarmstufen
        if (curve.isDisplayAlarmLevel()) {
            final AlarmLevel[] alarms = curve.getAlarmLevels();
            for (final AlarmLevel element : alarms) {
                final Double value = new Double(element.value);
                if (!m_yConsts.containsKey(value)) {
                    final XYCurveSerie xyc = m_curve2serie.get(curve);
                    final double x;
                    if (xyc.getItemCount() > 1)
                        x = xyc.getXValue(1).doubleValue();
                    else
                        x = getDomainAxis().getLowerBound();

                    final AlarmLevelPlotElement vac = new AlarmLevelPlotElement(element, x, xyc.getYDiagAxis());
                    m_yConsts.put(value, vac);
                }
            }
        }
    }
}

From source file:org.deidentifier.arx.DataHandle.java

/**
 * Returns a double value from the specified cell.
 *
 * @param row The cell's row index//from   w w w. j  a  v  a 2s  .c o  m
 * @param col The cell's column index
 * @return the double
 * @throws ParseException the parse exception
 */
public Double getDouble(int row, int col) throws ParseException {
    String value = getValue(row, col);
    DataType<?> type = getDataType(getAttributeName(col));
    if (type instanceof ARXDecimal) {
        return ((ARXDecimal) type).parse(value);
    } else if (type instanceof ARXInteger) {
        Long _long = ((ARXInteger) type).parse(value);
        return _long == null ? null : _long.doubleValue();
    } else {
        throw new ParseException("Invalid datatype: " + type.getClass().getSimpleName(), col);
    }
}

From source file:com.heneryh.aquanotes.ui.controllers.GraphsFragment.java

/**
 * Handle {@link VendorsQuery} {@link Cursor}.
 *//*from   w  w w. ja v a  2s .c o m*/
private void onProbeDataQueryComplete(Cursor cursor) {
    if (mCursor != null) {
        // In case cancelOperation() doesn't work and we end up with consecutive calls to this
        // callback.
        getActivity().stopManagingCursor(mCursor);
        mCursor = null;
    }
    mySimpleXYPlot = (XYPlot) mRootView.findViewById(R.id.mySimpleXYPlot);
    mySimpleXYPlot.setOnTouchListener(this);
    mySimpleXYPlot.clear();

    //Creation of the series
    final Vector<Double> vector = new Vector<Double>();
    int numDataPoints = 0;
    String probeName = null;
    Long timestamp = (long) 0;
    String valueS = null;
    try {
        /** For each datapoint in the database, */
        while (cursor.moveToNext()) {
            probeName = cursor.getString(ProbeDataViewQuery.NAME);
            timestamp = cursor.getLong(ProbeDataViewQuery.TIMESTAMP);
            valueS = cursor.getString(ProbeDataViewQuery.VALUE);
            Double valueD = Double.valueOf(valueS);
            vector.add(timestamp.doubleValue());
            vector.add(valueD);
            numDataPoints++;
        } // end of while()
    } finally {
        cursor.close();
        if (numDataPoints < 2)
            return;
    }
    // create our series from our array of nums:
    mySeries = new SimpleXYSeries(vector, ArrayFormat.XY_VALS_INTERLEAVED, probeName);

    mySimpleXYPlot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
    mySimpleXYPlot.getGraphWidget().getGridLinePaint().setColor(Color.BLACK);
    mySimpleXYPlot.getGraphWidget().getGridLinePaint()
            .setPathEffect(new DashPathEffect(new float[] { 1, 1 }, 1));
    mySimpleXYPlot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    mySimpleXYPlot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    mySimpleXYPlot.setBorderStyle(Plot.BorderStyle.SQUARE, null, null);
    mySimpleXYPlot.getBorderPaint().setStrokeWidth(1);
    mySimpleXYPlot.getBorderPaint().setAntiAlias(false);
    mySimpleXYPlot.getBorderPaint().setColor(Color.WHITE);

    // Create a formatter to use for drawing a series using LineAndPointRenderer:
    LineAndPointFormatter series1Format = new LineAndPointFormatter(Color.rgb(0, 100, 0), // line color
            Color.rgb(0, 100, 0), // point color
            Color.rgb(100, 200, 0)); // fill color

    // setup our line fill paint to be a slightly transparent gradient:
    Paint lineFill = new Paint();
    lineFill.setAlpha(200);
    //lineFill.setShader(new LinearGradient(0, 0, 0, 250, Color.WHITE, Color.GREEN, Shader.TileMode.MIRROR));

    LineAndPointFormatter formatter = new LineAndPointFormatter(Color.rgb(0, 0, 0), Color.BLUE, Color.RED);
    //       formatter.setFillPaint(lineFill);
    formatter.setFillPaint(null);
    //       formatter.setVertexPaint(null);
    formatter.getLinePaint().setShadowLayer(0, 0, 0, 0);
    mySimpleXYPlot.getGraphWidget().setPaddingRight(2);
    mySimpleXYPlot.addSeries(mySeries, formatter);

    // draw a domain tick for each year:
    //mySimpleXYPlot.setDomainStep(XYStepMode.SUBDIVIDE, numDataPoints);

    // customize our domain/range labels
    mySimpleXYPlot.setDomainLabel("Time");
    mySimpleXYPlot.setRangeLabel(probeName);

    // get rid of decimal points in our range labels:
    mySimpleXYPlot.setRangeValueFormat(new DecimalFormat("#0.00"));

    mySimpleXYPlot.setDomainValueFormat(new MyDateFormat());

    // by default, AndroidPlot displays developer guides to aid in laying out your plot.
    // To get rid of them call disableAllMarkup():
    mySimpleXYPlot.disableAllMarkup();

    //Set of internal variables for keeping track of the boundaries
    mySimpleXYPlot.calculateMinMaxVals();
    minXY = new PointF(mySimpleXYPlot.getCalculatedMinX().floatValue(),
            mySimpleXYPlot.getCalculatedMinY().floatValue()); //initial minimum data point
    absMinX = minXY.x; //absolute minimum data point
    //absolute minimum value for the domain boundary maximum
    minNoError = Math.round(mySeries.getX(1).floatValue() + 2);
    maxXY = new PointF(mySimpleXYPlot.getCalculatedMaxX().floatValue(),
            mySimpleXYPlot.getCalculatedMaxY().floatValue()); //initial maximum data point
    absMaxX = maxXY.x; //absolute maximum data point
    //absolute maximum value for the domain boundary minimum
    maxNoError = (float) Math.round(mySeries.getX(mySeries.size() - 1).floatValue()) - 2;

    //Check x data to find the minimum difference between two neighboring domain values
    //Will use to prevent zooming further in than this distance
    double temp1 = mySeries.getX(0).doubleValue();
    double temp2 = mySeries.getX(1).doubleValue();
    double temp3;
    double thisDif;
    minDif = 100000000; //increase if necessary for domain values
    for (int i = 2; i < mySeries.size(); i++) {
        temp3 = mySeries.getX(i).doubleValue();
        thisDif = Math.abs(temp1 - temp3);
        if (thisDif < minDif)
            minDif = thisDif;
        temp1 = temp2;
        temp2 = temp3;
    }
    minDif = minDif + difPadding; //with padding, the minimum difference

    mySimpleXYPlot.redraw();

}

From source file:org.apache.solr.update.processor.AddSchemaFieldsUpdateProcessorFactoryTest.java

public void testMultipleFieldsRoundTrip() throws Exception {
    IndexSchema schema = h.getCore().getLatestSchema();
    final String fieldName1 = "newfield5";
    final String fieldName2 = "newfield6";
    assertNull(schema.getFieldOrNull(fieldName1));
    assertNull(schema.getFieldOrNull(fieldName2));
    Float field1Value1 = -13258.0f;
    Double field1Value2 = 8.4828800808E10;
    Long field1Value3 = 999L;
    Integer field2Value1 = 55123;
    Long field2Value2 = 1234567890123456789L;
    SolrInputDocument d = processAdd("add-fields",
            doc(f("id", "5"), f(fieldName1, field1Value1, field1Value2, field1Value3),
                    f(fieldName2, field2Value1, field2Value2)));
    assertNotNull(d);//from  w w  w .ja va2s.co m
    schema = h.getCore().getLatestSchema();
    assertNotNull(schema.getFieldOrNull(fieldName1));
    assertNotNull(schema.getFieldOrNull(fieldName2));
    assertEquals("tdouble", schema.getFieldType(fieldName1).getTypeName());
    assertEquals("tlong", schema.getFieldType(fieldName2).getTypeName());
    assertU(commit());
    assertQ(req("id:5"), "//arr[@name='" + fieldName1 + "']/double[.='" + field1Value1.toString() + "']",
            "//arr[@name='" + fieldName1 + "']/double[.='" + field1Value2.toString() + "']",
            "//arr[@name='" + fieldName1 + "']/double[.='" + field1Value3.doubleValue() + "']",
            "//arr[@name='" + fieldName2 + "']/long[.='" + field2Value1.toString() + "']",
            "//arr[@name='" + fieldName2 + "']/long[.='" + field2Value2.toString() + "']");
}

From source file:com.intuit.tank.vm.settings.AgentConfigCpTest.java

/**
 * Run the Long getConnectionTimeout() method test.
 * /* w w w  .  j  a v  a2s.  c om*/
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:44 PM
 */
@Test
public void testGetConnectionTimeout_1() throws Exception {
    AgentConfig fixture = new AgentConfig(new HierarchicalConfiguration());
    fixture.setResultsTypeMap(new HashMap());

    Long result = fixture.getConnectionTimeout();

    assertNotNull(result);
    assertEquals("40000", result.toString());
    assertEquals((byte) 64, result.byteValue());
    assertEquals((short) -25536, result.shortValue());
    assertEquals(40000, result.intValue());
    assertEquals(40000L, result.longValue());
    assertEquals(40000.0f, result.floatValue(), 1.0f);
    assertEquals(40000.0, result.doubleValue(), 1.0);
}

From source file:com.bigdata.dastor.db.ColumnFamilyStore.java

public double getBloomFilterFalseRatio() {
    Long falseCount = 0L;
    Long trueCount = 0L;//from  w w w .  j a v a 2s  .com
    for (SSTableReader sstable : getSSTables()) {
        falseCount += sstable.getBloomFilterFalsePositiveCount();
        trueCount += sstable.getBloomFilterTruePositiveCount();
    }
    if (falseCount.equals(0L) && trueCount.equals(0L))
        return 0d;
    return falseCount.doubleValue() / (trueCount.doubleValue() + falseCount.doubleValue());
}

From source file:com.bigdata.dastor.db.ColumnFamilyStore.java

public double getRecentBloomFilterFalseRatio() {
    Long falseCount = 0L;
    Long trueCount = 0L;/*from  w w w .  j  a  v a2s.  c  o m*/
    for (SSTableReader sstable : getSSTables()) {
        falseCount += sstable.getRecentBloomFilterFalsePositiveCount();
        trueCount += sstable.getRecentBloomFilterTruePositiveCount();
    }
    if (falseCount.equals(0L) && trueCount.equals(0L))
        return 0d;
    return falseCount.doubleValue() / (trueCount.doubleValue() + falseCount.doubleValue());
}

From source file:ch.icclab.cyclops.client.UdrServiceClient.java

/**
 * Connects to the UDR Service and requests for the CDRs for a user between a time period
 *
 * @param from   String/*from w  w  w. j a  v a 2  s .c o  m*/
 * @param to     String
 * @param userId String
 * @param resourceId String
 * @return String
 */
public String getUserUsageData(String userId, String resourceId, Integer from, Integer to) {
    logger.trace(
            "BEGIN UserUsage getUserUsageData(String userId, String resourceId, Integer from, Integer to) throws IOException");
    logger.trace("DATA UserUsage getUserUsageData...: user=" + userId);
    Gson gson = new Gson();
    LinearRegressionPredict predict = new LinearRegressionPredict();
    //parse dates
    DateTime now = new DateTime(DateTimeZone.UTC);
    Long time_to = now.plusDays(to).getMillis();
    String time_string_from = now.minusDays(from).toString("yyyy-MM-dd'T'HH:mm:ss'Z'");
    ArrayList<Double> list_of_points = Time.makeListOfTIme(now, time_to, to);

    ClientResource resource = new ClientResource(url + "/usage/users/" + userId);
    resource.getReference().addQueryParameter("from", time_string_from);
    logger.trace("DATA UserUsage getUserUsageData...: url=" + resource.toString());
    resource.get(MediaType.APPLICATION_JSON);
    Representation output = resource.getResponseEntity();
    PredictionResponse result = new PredictionResponse();
    try {
        JSONObject resultArray = new JSONObject(output.getText());
        logger.trace("DATA UserUsage getUserUsageData...: output=" + resultArray.toString());
        logger.trace("DATA UserUsage getUsageUsageData...: resultArray=" + resultArray);
        String result_array = resultArray.toString();
        if (result_array.contains("OpenStack")) {
            result_array = result_array.replace("OpenStack", "External");
        }
        UdrServiceResponse usageDataRecords = gson.fromJson(result_array, UdrServiceResponse.class);
        logger.trace("DATA UserUsage getUserUsageData...: userUsageData=" + usageDataRecords);
        result = predict.predict(usageDataRecords, resourceId, list_of_points);
        // Fit "from" and "to" fields
        result.setFrom(time_string_from);
        result.setTo(Time.MillsToString(time_to.doubleValue()));
        logger.trace("DATA UserUsage getUserUsageData...: userUsageData=" + gson.toJson(result));

    } catch (JSONException e) {
        e.printStackTrace();
        logger.error("EXCEPTION JSONEXCEPTION UserUsage getUserUsageData...");
    } catch (IOException e) {
        logger.error("EXCEPTION IOEXCEPTION UserUsage getUserUsageData...");
        e.printStackTrace();
    }

    return gson.toJson(result);
}

From source file:com.silverpeas.servlets.upload.AjaxFileUploadServlet.java

/**
 * Return the current status of the upload.
 *
 * @param session the HttpSession./* w w w  . ja  v  a  2 s.  c  om*/
 * @param response where the status is to be written.
 * @throws IOException
 */
private void doStatus(HttpSession session, HttpServletResponse response) throws IOException {
    boolean isSavingUploadedFiles = isSavingUploadedFile(session);
    Long bytesProcessed = null;
    Long totalSize = null;
    FileUploadListener.FileUploadStats fileUploadStats = (FileUploadListener.FileUploadStats) session
            .getAttribute(FILE_UPLOAD_STATS);
    if (fileUploadStats != null) {
        bytesProcessed = fileUploadStats.getBytesRead();
        totalSize = fileUploadStats.getTotalSize();
    }

    // Make sure the status response is not cached by the browser
    response.addHeader("Expires", "0");
    response.addHeader("Cache-Control", "no-store, no-cache, must-revalidate");
    response.addHeader("Cache-Control", "post-check=0, pre-check=0");
    response.addHeader("Pragma", "no-cache");

    String fatalError = (String) session.getAttribute(UPLOAD_FATAL_ERROR);
    if (StringUtil.isDefined(fatalError)) {
        List<String> paths = (List<String>) session.getAttribute(FILE_UPLOAD_PATHS);
        String uploadedFilePaths = getUploadedFilePaths(paths);
        response.getWriter().println("<b>Upload uncomplete.</b>");
        response.getWriter().println("<script type='text/javascript'>window.parent.stop('" + fatalError + "', "
                + uploadedFilePaths + "); stop('" + fatalError + "', " + uploadedFilePaths + ");</script>");
        return;
    }

    if (bytesProcessed != null) {
        long percentComplete = (long) Math
                .floor((bytesProcessed.doubleValue() / totalSize.doubleValue()) * 100.0);
        response.getWriter().println("<b>Upload Status:</b><br/>");

        if (!bytesProcessed.equals(totalSize)) {
            response.getWriter().println("<div class=\"prog-border\"><div class=\"prog-bar\" style=\"width: "
                    + percentComplete + "%;\"></div></div>");
        } else {
            response.getWriter()
                    .println("<div class=\"prog-border\"><div class=\"prog-bar\" style=\"width: 100%;"
                            + "\"></div></div>");

            if (!isSavingUploadedFiles) {
                List<String> paths = (List<String>) session.getAttribute(FILE_UPLOAD_PATHS);
                String uploadedFilePaths = getUploadedFilePaths(paths);
                String errors = (String) session.getAttribute(UPLOAD_ERRORS);
                if (StringUtil.isDefined(errors)) {
                    response.getWriter().println("<b>Upload complete with error(s).</b><br/>");
                } else {
                    response.getWriter().println("<b>Upload complete.</b><br/>");
                    errors = "";
                }
                response.getWriter()
                        .println("<script type='text/javascript'>window.parent.stop('" + errors + "', "
                                + uploadedFilePaths + "); stop('" + errors + "', " + uploadedFilePaths
                                + ");</script>");
            }
        }
    }
}