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:org.yccheok.jstock.gui.charting.ChartJDialog.java

/**
 * Zoom in to this chart with specific amount of time.
 * @param field the calendar field./*from www .ja v a2 s  .  c om*/
 * @param amount the amount of date or time to be added to the field.
 */
private void _zoom(int field, int amount) {
    this.chartPanel.restoreAutoBounds();

    final int itemCount = this.priceTimeSeries.getItemCount();
    final Day day = (Day) this.priceTimeSeries.getDataItem(itemCount - 1).getPeriod();
    // Candle stick takes up half day space.
    // Volume price chart's volume information takes up whole day space.
    final long end = day.getFirstMillisecond()
            + (this.getCurrentType() == Type.Candlestick ? (1000 * 60 * 60 * 12) : (1000 * 60 * 60 * 24 - 1));
    final Calendar calendar = Calendar.getInstance();
    // -1. Calendar's month is 0 based but JFreeChart's month is 1 based.
    calendar.set(day.getYear(), day.getMonth() - 1, day.getDayOfMonth(), 0, 0, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    calendar.add(field, amount);
    // Candle stick takes up half day space.
    // Volume price chart's volume information does not take up any space.
    final long start = Math.max(0, calendar.getTimeInMillis()
            - (this.getCurrentType() == Type.Candlestick ? (1000 * 60 * 60 * 12) : 0));
    final ValueAxis valueAxis = this.getPlot().getDomainAxis();

    if (priceTimeSeries.getItemCount() > 0) {
        if (start < priceTimeSeries.getTimePeriod(0).getFirstMillisecond()) {
            // To prevent zoom-out too much.
            // This happens when user demands for 10 years zoom, where we
            // are only having 5 years data.
            return;
        }
    }

    valueAxis.setRange(start, end);

    double min = Double.MAX_VALUE;
    double max = Double.MIN_VALUE;
    double max_volume = Double.MIN_VALUE;
    final DefaultHighLowDataset defaultHighLowDataset = (DefaultHighLowDataset) this.priceOHLCDataset;

    for (int i = itemCount - 1; i >= 0; i--) {
        final TimeSeriesDataItem item = this.priceTimeSeries.getDataItem(i);
        final Day d = (Day) item.getPeriod();
        if (d.getFirstMillisecond() < start) {
            break;
        }

        final double high = defaultHighLowDataset.getHighValue(0, i);
        final double low = defaultHighLowDataset.getLowValue(0, i);
        final double volume = defaultHighLowDataset.getVolumeValue(0, i);

        if (max < high) {
            max = high;
        }
        if (min > low) {
            min = low;
        }
        if (max_volume < volume) {
            max_volume = volume;
        }
    }

    if (min > max) {
        return;
    }

    final ValueAxis rangeAxis = this.getPlot().getRangeAxis();
    final Range rangeAxisRange = rangeAxis.getRange();
    // Increase each side by 1%
    double tolerance = 0.01 * (max - min);
    // The tolerance must within range [0.01, 1.0]
    tolerance = Math.min(Math.max(0.01, tolerance), 1.0);
    // The range must within the original chart range.
    min = Math.max(rangeAxisRange.getLowerBound(), min - tolerance);
    max = Math.min(rangeAxisRange.getUpperBound(), max + tolerance);

    this.getPlot().getRangeAxis().setRange(min, max);

    if (this.getPlot().getRangeAxisCount() > 1) {
        final double volumeUpperBound = this.getPlot().getRangeAxis(1).getRange().getUpperBound();
        final double suggestedVolumneUpperBound = max_volume * 4;
        // To prevent over zoom-in.
        if (suggestedVolumneUpperBound < volumeUpperBound) {
            this.getPlot().getRangeAxis(1).setRange(0, suggestedVolumneUpperBound);
        }
    }
}

From source file:lucee.runtime.tag.Chart.java

private CategoryDataset createDatasetCategory() {
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Iterator<ChartSeriesBean> it = _series.iterator();
    //int seriesCount=_series.size();
    Iterator itt;/* w ww .  j a  v a2  s  .c o  m*/
    List datas;
    ChartSeriesBean csb;
    ChartDataBean cdb;
    int count = 0;
    smallest = Double.MAX_VALUE;
    biggest = Double.MIN_VALUE;
    String label;
    boolean hasLabels = false;
    while (it.hasNext()) {
        count++;
        csb = it.next();
        label = csb.getSeriesLabel();
        if (StringUtil.isEmpty(label))
            label = "" + count;
        else
            hasLabels = true;
        datas = csb.getDatas();
        if (sortxaxis)
            Collections.sort(datas);
        itt = datas.iterator();
        while (itt.hasNext()) {
            cdb = (ChartDataBean) itt.next();
            if (smallest > cdb.getValue())
                smallest = cdb.getValue();
            if (biggest < cdb.getValue())
                biggest = cdb.getValue();
            //if(seriesCount>1)

            dataset.addValue(cdb.getValue(), label, cdb.getItemAsString());

            //else dataset.addValue(cdb.getValue(), cdb.getItem(),"");

        }
    }
    if (!hasLabels)
        showlegend = false;
    return dataset;
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java

public void updateMessageSentStates() {
    dateStampsSeen.clear();// ww w  .ja  va 2  s.  co  m
    MessageCenterUtil.CompoundMessageCommonInterface lastSent = null;
    Set<String> uniqueNonce = new HashSet<String>();
    int removedItems = 0;
    ListIterator<MessageCenterListItem> listItemIterator = listItems.listIterator();
    while (listItemIterator.hasNext()) {
        int adapterMessagePosition = listItemIterator.nextIndex() - removedItems;
        MessageCenterListItem message = listItemIterator.next();
        if (message instanceof ApptentiveMessage) {
            /* Check if there is any duplicate messages and remove if found.
            * add() of a Set returns false if the element already exists.
             */
            if (!uniqueNonce.add(((ApptentiveMessage) message).getNonce())) {
                listItemIterator.remove();
                messageCenterRecyclerViewAdapter.notifyItemRemoved(adapterMessagePosition);
                removedItems++;
                continue;
            }
            // Update timestamps
            ApptentiveMessage apptentiveMessage = (ApptentiveMessage) message;
            Double sentOrReceivedAt = apptentiveMessage.getCreatedAt();
            String dateStamp = createDatestamp(sentOrReceivedAt);
            if (dateStamp != null) {
                if (dateStampsSeen.add(dateStamp)) {
                    if (apptentiveMessage.setDatestamp(dateStamp)) {
                        messageCenterRecyclerViewAdapter.notifyItemChanged(adapterMessagePosition);
                    }
                } else {
                    if (apptentiveMessage.clearDatestamp()) {
                        messageCenterRecyclerViewAdapter.notifyItemChanged(adapterMessagePosition);
                    }
                }
            }

            //Find last sent
            if (apptentiveMessage.isOutgoingMessage()) {
                if (sentOrReceivedAt != null && sentOrReceivedAt > Double.MIN_VALUE) {
                    lastSent = (MessageCenterUtil.CompoundMessageCommonInterface) apptentiveMessage;
                    lastSent.setLastSent(false);
                }

            }
        }
    }

    if (lastSent != null) {
        lastSent.setLastSent(true);
    }
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java

protected String createDatestamp(Double seconds) {
    if (seconds != null && seconds > Double.MIN_VALUE) {
        Date date = new Date(Math.round(seconds * 1000));
        DateFormat mediumDateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
        return mediumDateFormat.format(date);
    }/*from w w w  .  j  ava  2s.  co  m*/
    return null;
}

From source file:lucee.runtime.tag.Chart.java

private XYDataset createTimeSeriesCollection() {
    TimeZone tz = ThreadLocalPageContext.getTimeZone();
    final TimeSeriesCollection coll = new TimeSeriesCollection(tz);

    //final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Iterator<ChartSeriesBean> it = _series.iterator();
    //int seriesCount=_series.size();
    Iterator itt;/*from  www . j a va  2  s  . c  om*/
    List datas;
    ChartSeriesBean csb;
    ChartDataBean cdb;
    int count = 0;
    smallest = Double.MAX_VALUE;
    biggest = Double.MIN_VALUE;
    String label;
    boolean hasLabels = false;
    while (it.hasNext()) {
        count++;
        csb = it.next();
        label = csb.getSeriesLabel();
        if (StringUtil.isEmpty(label))
            label = "" + count;
        else
            hasLabels = true;
        datas = csb.getDatas();
        if (sortxaxis)
            Collections.sort(datas);
        itt = datas.iterator();
        TimeSeries ts = new TimeSeries(label, Second.class);
        while (itt.hasNext()) {
            cdb = (ChartDataBean) itt.next();
            if (smallest > cdb.getValue())
                smallest = cdb.getValue();
            if (biggest < cdb.getValue())
                biggest = cdb.getValue();
            //if(seriesCount>1)
            ts.addOrUpdate(new Second(
                    DateCaster.toDateSimple(cdb.getItem(), DateCaster.CONVERTING_TYPE_NONE, false, tz, null)),
                    cdb.getValue());

            //else dataset.addValue(cdb.getValue(), cdb.getItem(),"");

        }
        coll.addSeries(ts);
    }
    if (!hasLabels)
        showlegend = false;
    return coll;
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java

private void prepareMessages(final List<MessageCenterListItem> originalItems) {
    listItems.clear();/*from  w ww .j  a va2  s .  c om*/
    unsentMessagesCount = 0;
    // Loop through each message item retrieved from database
    for (MessageCenterListItem item : originalItems) {
        if (item instanceof ApptentiveMessage) {
            ApptentiveMessage apptentiveMessage = (ApptentiveMessage) item;
            Double createdAt = apptentiveMessage.getCreatedAt();
            if (apptentiveMessage.isOutgoingMessage() && createdAt == null) {
                unsentMessagesCount++;
            }

            /*
             * Find proper location to insert into the listItems list of the listview.
             */
            ListIterator<MessageCenterListItem> listIterator = listItems.listIterator();
            ApptentiveMessage next = null;
            while (listIterator.hasNext()) {
                next = (ApptentiveMessage) listIterator.next();
                Double nextCreatedAt = next.getCreatedAt();
                // For unsent and dropped message, move the iterator to the end, and append there
                if (createdAt == null || createdAt <= Double.MIN_VALUE) {
                    continue;
                }
                // next message has not received by server or received, but has a later created_at time
                if (nextCreatedAt == null || nextCreatedAt > createdAt) {
                    break;
                }
            }

            if (next == null || next.getCreatedAt() == null || createdAt == null
                    || next.getCreatedAt() <= createdAt || createdAt <= Double.MIN_VALUE) {
                listIterator.add(item);
            } else {
                // Add in front of the message that has later created_at time
                listIterator.set(item);
                listIterator.add(next);
            }
        }
    }
    messagingActionHandler.sendEmptyMessage(MSG_ADD_GREETING);
}

From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterActivityContent.java

public void updateMessageSentStates() {
    dateStampsSeen.clear();// w ww  .j av  a  2s  . c  o  m
    MessageCenterUtil.CompoundMessageCommonInterface lastSent = null;
    Set<String> uniqueNonce = new HashSet<String>();
    Iterator<MessageCenterListItem> messageIterator = messages.iterator();
    while (messageIterator.hasNext()) {
        MessageCenterListItem message = messageIterator.next();
        if (message instanceof ApptentiveMessage) {
            /* Check if there is any duplicate messages and remove if found.
            * add() of a Set returns false if the element already exists.
             */
            if (!uniqueNonce.add(((ApptentiveMessage) message).getNonce())) {
                messageIterator.remove();
                continue;
            }
            // Update timestamps
            ApptentiveMessage apptentiveMessage = (ApptentiveMessage) message;
            Double sentOrReceivedAt = apptentiveMessage.getCreatedAt();
            String dateStamp = createDatestamp(sentOrReceivedAt);
            if (dateStamp != null) {
                if (dateStampsSeen.add(dateStamp)) {
                    apptentiveMessage.setDatestamp(dateStamp);
                } else {
                    apptentiveMessage.clearDatestamp();
                }
            }

            //Find last sent
            if (apptentiveMessage.isOutgoingMessage()) {
                if (sentOrReceivedAt != null && sentOrReceivedAt > Double.MIN_VALUE) {
                    lastSent = (MessageCenterUtil.CompoundMessageCommonInterface) apptentiveMessage;
                    lastSent.setLastSent(false);
                }

            }
        }
    }

    if (lastSent != null) {
        lastSent.setLastSent(true);
    }
}

From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterActivityContent.java

private void prepareMessages(final List<MessageCenterListItem> originalItems) {
    messages.clear();//from  w ww  .  ja v a  2  s  .com
    unsendMessagesCount = 0;
    // Loop through each message item retrieved from database
    for (MessageCenterListItem item : originalItems) {
        if (item instanceof ApptentiveMessage) {
            ApptentiveMessage apptentiveMessage = (ApptentiveMessage) item;
            Double createdAt = apptentiveMessage.getCreatedAt();
            if (apptentiveMessage.isOutgoingMessage() && createdAt == null) {
                unsendMessagesCount++;
            }

            /*
             * Find proper location to insert into the messages list of the listview.
             */
            ListIterator<MessageCenterListItem> listIterator = messages.listIterator();
            ApptentiveMessage next = null;
            while (listIterator.hasNext()) {
                next = (ApptentiveMessage) listIterator.next();
                Double nextCreatedAt = next.getCreatedAt();
                // For unsent and dropped message, move the iterator to the end, and append there
                if (createdAt == null || createdAt <= Double.MIN_VALUE) {
                    continue;
                }
                // next message has not received by server or received, but has a later created_at time
                if (nextCreatedAt == null || nextCreatedAt > createdAt) {
                    break;
                }
            }

            if (next == null || next.getCreatedAt() == null || createdAt == null
                    || next.getCreatedAt() <= createdAt || createdAt <= Double.MIN_VALUE) {
                listIterator.add(item);
            } else {
                // Add in front of the message that has later created_at time
                listIterator.set(item);
                listIterator.add(next);
            }
        }
    }
    // Finally, add greeting message
    messages.add(0, interaction.getGreeting());
}

From source file:org.apache.noggit.JSONParser.java

public void testNumbers() throws IOException {
        err("[00]");
        err("[003]");
        err("[00.3]");
        err("[1e1.1]");
        err("[+1]");
        err("[NaN]");
        err("[Infinity]");
        err("[--1]");

        String lmin = "-9223372036854775808";
        String lminNot = "-9223372036854775809";
        String lmax = "9223372036854775807";
        String lmaxNot = "9223372036854775808";

        String bignum = "12345678987654321357975312468642099775533112244668800152637485960987654321";

        parse("[0,1,-1,543,-876]", new Object[] { a, o(0), o(1), o(-1), o(543), o(-876), A, e });
        parse("[-0]", new Object[] { a, o(0), A, e });

        parse("[" + lmin + "," + lmax + "]", new Object[] { a, o(Long.MIN_VALUE), o(Long.MAX_VALUE), A, e });

        parse("[" + bignum + "]", new Object[] { a, bn(bignum), A, e });
        parse("[" + "-" + bignum + "]", new Object[] { a, bn("-" + bignum), A, e });

        parse("[" + lminNot + "]", new Object[] { a, bn(lminNot), A, e });
        parse("[" + lmaxNot + "]", new Object[] { a, bn(lmaxNot), A, e });

        parse("[" + lminNot + "," + lmaxNot + "]", new Object[] { a, bn(lminNot), bn(lmaxNot), A, e });

        // bignum many digits on either side of decimal
        String t = bignum + "." + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        err(t + ".1"); // extra decimal
        err("-" + t + ".1");

        // bignum exponent w/o fraction
        t = "1" + "e+" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        t = "1" + "E+" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        t = "1" + "e" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        t = "1" + "E" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        t = "1" + "e-" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        t = "1" + "E-" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });

        t = bignum + "e+" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        t = bignum + "E-" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        t = bignum + "e" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });

        t = bignum + "." + bignum + "e" + bignum;
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });

        err("[1E]");
        err("[1E-]");
        err("[1E+]");
        err("[1E+.3]");
        err("[1E+0.3]");
        err("[1E+1e+3]");
        err("[" + bignum + "e" + "]");
        err("[" + bignum + "e-" + "]");
        err("[" + bignum + "e+" + "]");
        err("[" + bignum + "." + bignum + "." + bignum + "]");

        double[] vals = new double[] { 0, 0.1, 1.1, Double.MAX_VALUE, Double.MIN_VALUE,
                2.2250738585072014E-308, /* Double.MIN_NORMAL */
        };/* w w  w  .  j a  va2 s . c om*/
        for (int i = 0; i < vals.length; i++) {
            double d = vals[i];
            parse("[" + d + "," + -d + "]", new Object[] { a, o(d), o(-d), A, e });
        }

        // MIN_NORMAL has the max number of digits (23), so check that
        // adding an extra digit causes BIGNUM to be returned.
        t = "2.2250738585072014E-308" + "0";
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
        // check it works with a leading zero too
        t = "0.2250738585072014E-308" + "0";
        parse("[" + t + "," + "-" + t + "]", new Object[] { a, bn(t), bn("-" + t), A, e });
    }

From source file:org.hyperic.hq.measurement.server.session.DataManagerImpl.java

private final double[] getAggData(final List<HighLowMetricValue> historicalData) {
    if (historicalData.size() == 0) {
        return null;
    }//from  w w w . ja v a  2 s  .co m
    double high = Double.MIN_VALUE;
    double low = Double.MAX_VALUE;
    double total = 0;
    Double lastVal = null;
    int count = 0;
    long last = Long.MIN_VALUE;
    for (HighLowMetricValue mv : historicalData) {
        low = Math.min(mv.getLowValue(), low);
        high = Math.max(mv.getHighValue(), high);
        if (mv.getTimestamp() > last) {
            lastVal = new Double(mv.getValue());
        }
        final int c = mv.getCount();
        count = count + c;
        total = ((mv.getValue() * c) + total);
    }
    final double[] data = new double[MeasurementConstants.IND_LAST_TIME + 1];
    data[MeasurementConstants.IND_MIN] = low;
    data[MeasurementConstants.IND_AVG] = total / count;
    data[MeasurementConstants.IND_MAX] = high;
    data[MeasurementConstants.IND_CFG_COUNT] = count;
    if (lastVal != null) {
        data[MeasurementConstants.IND_LAST_TIME] = lastVal.doubleValue();
    }
    return data;
}