Example usage for java.lang Double MIN_VALUE

List of usage examples for java.lang Double MIN_VALUE

Introduction

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

Prototype

double MIN_VALUE

To view the source code for java.lang Double MIN_VALUE.

Click Source Link

Document

A constant holding the smallest positive nonzero value of type double , 2-1074.

Usage

From source file:de.ma.it.common.excel.ExcelFileManager.java

/**
 * //from  w  w  w.ja va2  s. c o  m
 * @param row
 * @param cellIdx
 * @return
 * @throws IllegalArgumentException
 */
public Double readCellAsDouble(HSSFRow row, int cellIdx) throws IllegalArgumentException {
    HSSFCell cell = getCell(row, cellIdx);
    if (cell == null) {
        return null;
    }

    int cellType = cell.getCellType();
    // First evaluate formula if present
    if (cellType == HSSFCell.CELL_TYPE_FORMULA) {
        cellType = evaluator.evaluateFormulaCell(cell);
    }

    Double result;
    switch (cellType) {
    case HSSFCell.CELL_TYPE_NUMERIC:
        double numericCellValue = cell.getNumericCellValue();
        result = Double.valueOf(numericCellValue);
        break;
    case HSSFCell.CELL_TYPE_STRING:
        String stringCellValue = cell.getStringCellValue();
        if (!StringUtils.isNumeric(stringCellValue)) {
            throw new IllegalArgumentException("Value " + stringCellValue + " is not numeric!");
        }
        result = Double.valueOf(stringCellValue);
        break;
    default:
        result = Double.MIN_VALUE;
        break;
    }

    return result;
}

From source file:org.eclipse.triquetrum.scisoft.analysis.rpc.flattening.FlatteningTestAbstract.java

@Test
public void testDouble() {
    flattenAndUnflatten(0);
    flattenAndUnflatten(Math.PI);
    flattenAndUnflatten(Double.MIN_VALUE);
    flattenAndUnflatten(Double.MAX_VALUE);
}

From source file:org.patientview.patientview.ResultsAction.java

/**
 * Converts a set of patient results to JSON data suitable for Google Charts integration on clientside
 * @param resultData A collection of Result objects containing patient test results
 * @param resultType1 The name of the first set of results to convert
 * @param resultType2 The name of the first set of results to convert (deprecated)
 * @return A JSON format string containing formatted results data suitable for Google Charts
 *//*from  ww w . j ava 2 s  . c  o  m*/
private String convertToJsonData(Collection<Result> resultData, String resultType1, String resultType2) {

    ResultHeadingManager resultHeadingManager = getWebApplicationContext().getBean(ResultHeadingManager.class);
    String resultValue1 = "";
    String resultValue2 = "";

    ResultHeading heading1 = resultHeadingManager.get(resultType1);
    ResultHeading heading2 = resultHeadingManager.get(resultType2);

    StringBuffer sb = new StringBuffer();
    // cols header
    sb.append("{\"cols\":[");
    // DateTime
    sb.append("{\"id\":\"DateTime\",\"label\":\"DateTime\",\"type\":\"string\"},");

    if (StringUtils.isNotEmpty(resultType1)) {
        // result type 1
        sb.append("{\"id\":\"").append(heading1.getHeading()).append("\",");
        sb.append("\"label\":\"").append(heading1.getHeading()).append("\",").append("\"type\":\"number\"},");
        // tooltip for result type 1
        sb.append("{\"id\":\"\",").append("\"role\":\"tooltip\",").append("\"type\":\"string\",");
        sb.append("\"p\":{\"role\":\"tooltip\",\"html\":\"true\"}}");

        if (StringUtils.isEmpty(resultType2)) {
            sb.append("],");
        } else {
            sb.append(",");
        }
    }

    if (StringUtils.isNotEmpty(resultType2)) {

        // result type 2
        sb.append("{\"id\":\"").append(heading2.getHeading()).append("\",");
        sb.append("\"label\":\"").append(heading2.getHeading()).append("\",").append("\"type\":\"number\"},");
        // tooltip result type 2
        sb.append("{\"id\":\"\",").append("\"role\":\"tooltip\",").append("\"type\":\"string\",");
        sb.append("\"p\":{\"role\":\"tooltip\",\"html\":\"true\"}}],");
    }

    // rows value
    sb.append("\"rows\":[");

    Double resultHeadingMinValue = heading1.getMinRangeValue();
    Double resultHeadingMaxValue = heading1.getMaxRangeValue();
    Double dataMinValue = Double.MAX_VALUE;
    Double dataMaxValue = Double.MIN_VALUE;

    for (Iterator iterator = resultData.iterator(); iterator.hasNext();) {
        Result result = (Result) iterator.next();
        resultValue1 = result.getValue(resultType1);
        resultValue2 = result.getValue(resultType2);

        try {
            if (Double.parseDouble(resultValue1) < dataMinValue) {
                dataMinValue = Double.parseDouble(resultValue1);
            }
        } catch (NumberFormatException e) {
            LOGGER.trace("NumberFormatException: " + e.toString());
        } catch (NullPointerException e) {
            LOGGER.trace("NullPointerException: " + e.toString());
        }

        try {
            if (Double.parseDouble(resultValue1) > dataMaxValue) {
                dataMaxValue = Double.parseDouble(resultValue1);
            }
        } catch (NumberFormatException e) {
            LOGGER.trace("NumberFormatException: " + e.toString());
        } catch (NullPointerException e) {
            LOGGER.trace("NullPointerException: " + e.toString());
        }

        sb.append("{\"c\":[");
        // DateTime
        sb.append("{\"v\":\"").append(dateFormat.format(result.getTimeStamp().getTime())).append("\"},");

        if (StringUtils.isNotEmpty(resultType1)) {
            // result type 1
            sb.append("{\"v\":\"").append(resultValue1).append("\"},");
            // tooltip for result type 1
            sb.append("{\"v\":\"").append(getHtmlTooltip(result, heading1, resultValue1));
            sb.append("\"}");

            if (StringUtils.isNotEmpty(resultType2)) {
                sb.append(",");
            }
        }

        if (StringUtils.isNotEmpty(resultType2)) {
            // column 3: result type 2
            sb.append("{\"v\":\"").append(resultValue2).append("\"},");
            // tooltip for result type 2
            sb.append("{\"v\":\"").append(getHtmlTooltip(result, heading2, resultValue2)).append("\"}");
        }

        if (iterator.hasNext()) {
            sb.append("]},");
        } else {
            sb.append("]}");
        }
    }

    // min value and max value (for graph range) from either data or result heading defaults, store in config tag

    sb.append("],\"config\": {\"minRangeValue\" : \"");

    // for minimum graph y-axis value uses the lowest of either the data's range or the ResultHeading.minvalue
    if (resultHeadingMinValue != null) {
        if (dataMinValue != Double.MAX_VALUE) {
            if (dataMinValue < resultHeadingMinValue) {
                sb.append(dataMinValue);
            } else {
                sb.append(resultHeadingMinValue);
            }
        }
    } else {
        sb.append(dataMinValue);
    }

    sb.append("\", \"maxRangeValue\" : \"");

    // for maximum graph y-axis value uses the highest of either the data's range or the ResultHeading.maxvalue
    if (resultHeadingMaxValue != null) {
        if (dataMaxValue != Double.MIN_VALUE) {
            if (dataMaxValue > resultHeadingMaxValue) {
                sb.append(dataMaxValue);
            } else {
                sb.append(resultHeadingMaxValue);
            }
        }
    } else {
        sb.append(dataMaxValue);
    }

    // title text (first result heading)
    if (heading1.getHeading() != null) {
        sb.append("\", \"titleText\" : \"");
        sb.append(heading1.getHeading());
    }

    // units (y-axis label)
    if (heading1.getUnits() != null) {
        sb.append("\", \"units\" : \"");
        sb.append(heading1.getUnits());
    }

    sb.append("\"}}");
    return sb.toString();
}

From source file:com.androzic.track.TrackDetails.java

private void updateTrackDetails() {
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    Resources resources = getResources();

    activity.getSupportActionBar().setTitle(track.name);

    View view = getView();//from  w w w.j  a  v  a  2s  .  c  o m

    int pointCount = track.getPointCount();
    ((TextView) view.findViewById(R.id.point_count))
            .setText(resources.getQuantityString(R.plurals.numberOfPoints, pointCount, pointCount));

    String distance = StringFormatter.distanceH(track.distance);
    ((TextView) view.findViewById(R.id.distance)).setText(distance);

    Track.TrackPoint ftp = track.getPoint(0);
    Track.TrackPoint ltp = track.getLastPoint();

    String start_coords = StringFormatter.coordinates(" ", ftp.latitude, ftp.longitude);
    ((TextView) view.findViewById(R.id.start_coordinates)).setText(start_coords);
    String finish_coords = StringFormatter.coordinates(" ", ltp.latitude, ltp.longitude);
    ((TextView) view.findViewById(R.id.finish_coordinates)).setText(finish_coords);

    Date start_date = new Date(ftp.time);
    ((TextView) view.findViewById(R.id.start_date))
            .setText(DateFormat.getDateFormat(activity).format(start_date) + " "
                    + DateFormat.getTimeFormat(activity).format(start_date));
    Date finish_date = new Date(ltp.time);
    ((TextView) view.findViewById(R.id.finish_date))
            .setText(DateFormat.getDateFormat(activity).format(finish_date) + " "
                    + DateFormat.getTimeFormat(activity).format(finish_date));

    long elapsed = (ltp.time - ftp.time) / 1000;
    String timeSpan;
    if (elapsed < 24 * 60 * 60 * 3) {
        timeSpan = DateUtils.formatElapsedTime(elapsed);
    } else {
        timeSpan = DateUtils.formatDateRange(activity, ftp.time, ltp.time, DateUtils.FORMAT_ABBREV_MONTH);
    }
    ((TextView) view.findViewById(R.id.time_span)).setText(timeSpan);

    // Gather statistics
    int segmentCount = 0;
    double minElevation = Double.MAX_VALUE;
    double maxElevation = Double.MIN_VALUE;
    double maxSpeed = 0;

    MeanValue mv = new MeanValue();

    for (Track.TrackSegment segment : track.getSegments()) {
        Track.TrackPoint ptp = null;
        if (segment.independent)
            segmentCount++;

        for (Track.TrackPoint tp : segment.getPoints()) {
            if (ptp != null) {
                double d = Geo.distance(tp.latitude, tp.longitude, ptp.latitude, ptp.longitude);
                double speed = d / ((tp.time - ptp.time) / 1000);
                if (speed == Double.POSITIVE_INFINITY)
                    continue;
                mv.addValue(speed);
                if (speed > maxSpeed)
                    maxSpeed = speed;
            }
            ptp = tp;
            if (tp.elevation < minElevation && tp.elevation != 0)
                minElevation = tp.elevation;
            if (tp.elevation > maxElevation)
                maxElevation = tp.elevation;
        }
    }

    double averageSpeed = mv.getMeanValue();

    ((TextView) view.findViewById(R.id.segment_count))
            .setText(resources.getQuantityString(R.plurals.numberOfSegments, segmentCount, segmentCount));

    ((TextView) view.findViewById(R.id.max_elevation)).setText(StringFormatter.elevationH(maxElevation));
    ((TextView) view.findViewById(R.id.min_elevation)).setText(StringFormatter.elevationH(minElevation));

    ((TextView) view.findViewById(R.id.max_speed)).setText(String.format(Locale.getDefault(), "%s: %s",
            resources.getString(R.string.max_speed), StringFormatter.speedH(maxSpeed)));
    ((TextView) view.findViewById(R.id.average_speed)).setText(String.format(Locale.getDefault(), "%s: %s",
            resources.getString(R.string.average_speed), StringFormatter.speedH(averageSpeed)));
}

From source file:org.apache.giraph.debugger.mock.FormatHelper.java

/**
 * Generates the line that constructs the given object, which can be
 * an int, boolean, char, byte, short, etc.
 * @param input object to construct in the unit test.
 * @return string generating the line that constructs the given object.
 *///w w  w.  ja v  a 2 s .  c  om
public String format(Object input) {
    if (input instanceof Boolean || input instanceof Byte || input instanceof Character
            || input instanceof Short || input instanceof Integer) {
        return input.toString();
    } else if (input instanceof Long) {
        return input.toString() + "l";
    } else if (input instanceof Float) {
        return decimalFormat.format(input) + "f";
    } else if (input instanceof Double) {
        double val = ((Double) input).doubleValue();
        if (val == Double.MAX_VALUE) {
            return "Double.MAX_VALUE";
        } else if (val == Double.MIN_VALUE) {
            return "Double.MIN_VALUE";
        } else {
            BigDecimal bd = new BigDecimal(val);
            return bd.toEngineeringString() + "d";
        }
    } else {
        return input.toString();
    }
}

From source file:com.ibm.bi.dml.runtime.controlprogram.parfor.opt.CostEstimator.java

/**
 * /*w w  w . ja  va 2s  . c o m*/
 * @param measure
 * @param nodes
 * @return
 * @throws DMLRuntimeException
 */
protected double getMaxEstimate(TestMeasure measure, ArrayList<OptNode> nodes, ExecType et)
        throws DMLRuntimeException {
    double max = Double.MIN_VALUE; //smallest positive value
    for (OptNode n : nodes) {
        double tmp = getEstimate(measure, n, et);
        if (tmp > max)
            max = tmp;
    }
    return max;
}

From source file:com.google.wireless.speed.speedometer.measurements.PingTask.java

private MeasurementResult constructResult(ArrayList<Double> rrtVals, double packetLoss, int packetsSent) {
    double min = Double.MAX_VALUE;
    double max = Double.MIN_VALUE;
    double mdev, avg, filteredAvg;
    double total = 0;
    boolean success = true;

    if (rrtVals.size() == 0) {
        return null;
    }// w  ww . j  ava 2 s. c om

    for (double rrt : rrtVals) {
        if (rrt < min) {
            min = rrt;
        }
        if (rrt > max) {
            max = rrt;
        }
        total += rrt;
    }

    avg = total / rrtVals.size();
    mdev = Util.getStandardDeviation(rrtVals, avg);
    filteredAvg = filterPingResults(rrtVals, avg);

    PhoneUtils phoneUtils = PhoneUtils.getPhoneUtils();

    MeasurementResult result = new MeasurementResult(phoneUtils.getDeviceInfo().deviceId,
            phoneUtils.getDeviceProperty(), PingTask.TYPE, System.currentTimeMillis() * 1000, success,
            this.measurementDesc);

    result.addResult("target_ip", targetIp);
    result.addResult("mean_rtt_ms", avg);
    result.addResult("min_rtt_ms", min);
    result.addResult("max_rtt_ms", max);
    result.addResult("stddev_rtt_ms", mdev);
    if (filteredAvg != avg) {
        result.addResult("filtered_mean_rtt_ms", filteredAvg);
    }
    result.addResult("packet_loss", packetLoss);
    result.addResult("packets_sent", packetsSent);
    return result;
}

From source file:com.vgi.mafscaling.OpenLoop.java

protected void createGraghTab() {
    JPanel cntlPanel = new JPanel();
    JPanel plotPanel = createGraphPlotPanel(cntlPanel);
    add(plotPanel, "<html><div style='text-align: center;'>C<br>h<br>a<br>r<br>t</div></html>");

    GridBagLayout gbl_cntlPanel = new GridBagLayout();
    gbl_cntlPanel.columnWidths = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_cntlPanel.rowHeights = new int[] { 0, 0 };
    gbl_cntlPanel.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_cntlPanel.rowWeights = new double[] { 0 };
    cntlPanel.setLayout(gbl_cntlPanel);/*w w w.j av  a 2  s.co  m*/

    GridBagConstraints gbc_check = new GridBagConstraints();
    gbc_check.insets = insets2;
    gbc_check.gridx = 0;
    gbc_check.gridy = 0;

    checkBoxMafRpmData = new JCheckBox("MafV/RPM");
    checkBoxMafRpmData.setActionCommand("mafrpm");
    checkBoxMafRpmData.addActionListener(this);
    cntlPanel.add(checkBoxMafRpmData, gbc_check);

    gbc_check.gridx++;
    checkBoxRunData = new JCheckBox("AFR Error");
    checkBoxRunData.setActionCommand("rdata");
    checkBoxRunData.addActionListener(this);
    cntlPanel.add(checkBoxRunData, gbc_check);

    gbc_check.gridx++;
    createGraphCommonControls(cntlPanel, gbc_check.gridx);

    createChart(plotPanel, Y2AxisName);
    createMafSmoothingPanel(plotPanel);
}

From source file:de.codesourcery.eve.skills.market.impl.MarketLogFile.java

public double getMaxPrice(final PriceInfo.Type type, final IMarketLogFilter filter) {

    final double[] maxPrice = new double[] { Double.MIN_VALUE };

    visit(new IMarketLogVisitor() {

        @Override/*from   ww  w  .j  a va2  s .  c o m*/
        public void visit(MarketLogEntry entry) {
            if (entry.getType().matches(type) && filter.includeInResult(entry)) {
                if (entry.getPrice() > maxPrice[0]) {
                    maxPrice[0] = entry.getPrice();
                }
            }
        }
    });

    if (maxPrice[0] == Double.MIN_VALUE) {
        return 0.0;
    }

    return maxPrice[0];
}

From source file:org.pentaho.platform.uifoundation.chart.DialWidgetDefinition.java

/**
 * TODO: PROBLEM HERE! See the note on the constructor above.
 * /* w w  w  .  ja  v  a  2  s . c om*/
 * @param document
 * @param value
 * @param width
 * @param height
 * @param session
 */
public DialWidgetDefinition(final Document document, final double value, final int width, final int height,
        final IPentahoSession session) {
    this(value, Double.MIN_VALUE, Double.MAX_VALUE, false);

    // get the dial node from the document
    attributes = document.selectSingleNode("//dial"); //$NON-NLS-1$

    deriveMinMax(value);

    // create the dial definition object
    DialWidgetDefinition.createDial(this, attributes, width, height, session);
}