Example usage for org.jfree.data.time TimeSeries getItemCount

List of usage examples for org.jfree.data.time TimeSeries getItemCount

Introduction

In this page you can find the example usage for org.jfree.data.time TimeSeries getItemCount.

Prototype

@Override
public int getItemCount() 

Source Link

Document

Returns the number of items in the series.

Usage

From source file:org.jfree.data.time.TimeSeries.java

/**
 * Returns a collection of time periods in the specified series, but not in
 * this series, and therefore unique to the specified series.
 *
 * @param series  the series to check against this one.
 *
 * @return The unique time periods./*from  w  w  w  . j a v  a  2 s .  c  o m*/
 */
public Collection getTimePeriodsUniqueToOtherSeries(TimeSeries series) {
    Collection result = new java.util.ArrayList();
    for (int i = 0; i < series.getItemCount(); i++) {
        RegularTimePeriod period = series.getTimePeriod(i);
        int index = getIndex(period);
        if (index < 0) {
            result.add(period);
        }
    }
    return result;
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * A test for the bug report 1075255./*w  ww . j  a  v  a  2s  .co  m*/
 */
@Test
public void testBug1075255() {
    TimeSeries ts = new TimeSeries("dummy");
    ts.add(new FixedMillisecond(0L), 0.0);
    TimeSeries ts2 = new TimeSeries("dummy2");
    ts2.add(new FixedMillisecond(0L), 1.0);
    try {
        ts.addAndOrUpdate(ts2);
    } catch (Exception e) {
        fail("No exceptions should be thrown.");
    }
    assertEquals(1, ts.getItemCount());
}

From source file:org.jfree.data.time.TimeSeries.java

/**
 * Adds or updates data from one series to another.  Returns another series
 * containing the values that were overwritten.
 *
 * @param series  the series to merge with this.
 *
 * @return A series containing the values that were overwritten.
 *///ww w  . j  a  v  a 2s  .  c o m
public TimeSeries addAndOrUpdate(TimeSeries series) {
    TimeSeries overwritten = new TimeSeries("Overwritten values from: " + getKey());
    for (int i = 0; i < series.getItemCount(); i++) {
        TimeSeriesDataItem item = series.getRawDataItem(i);
        TimeSeriesDataItem oldItem = addOrUpdate(item.getPeriod(), item.getValue());
        if (oldItem != null) {
            overwritten.add(oldItem);
        }
    }
    return overwritten;
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Basic tests for the delete() method.//from w ww . j a va2  s. c  o m
 */
@Test
public void testDelete2() {
    TimeSeries s1 = new TimeSeries("Series", Year.class);
    s1.add(new Year(2000), 13.75);
    s1.add(new Year(2001), 11.90);
    s1.add(new Year(2002), null);
    s1.addChangeListener(this);
    this.gotSeriesChangeEvent = false;
    s1.delete(new Year(2001));
    assertTrue(this.gotSeriesChangeEvent);
    assertEquals(2, s1.getItemCount());
    assertEquals(null, s1.getValue(new Year(2001)));

    // try deleting a time period that doesn't exist...
    this.gotSeriesChangeEvent = false;
    s1.delete(new Year(2006));
    assertFalse(this.gotSeriesChangeEvent);

    // try deleting null
    try {
        s1.delete(null);
        fail("Expected IllegalArgumentException.");
    } catch (IllegalArgumentException e) {
        // expected
    }
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Some checks for the removeAgedItems() method.
 *//*w w  w  . ja  v a 2 s  .c  o m*/
@Test
public void testRemoveAgedItems() {
    TimeSeries series = new TimeSeries("Test Series", Year.class);
    series.addChangeListener(this);
    assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
    assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
    this.gotSeriesChangeEvent = false;

    // test empty series
    series.removeAgedItems(true);
    assertEquals(0, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test series with one item
    series.add(new Year(1999), 1.0);
    series.setMaximumItemAge(0);
    this.gotSeriesChangeEvent = false;
    series.removeAgedItems(true);
    assertEquals(1, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test series with two items
    series.setMaximumItemAge(10);
    series.add(new Year(2001), 2.0);
    this.gotSeriesChangeEvent = false;
    series.setMaximumItemAge(2);
    assertEquals(2, series.getItemCount());
    assertEquals(0, series.getIndex(new Year(1999)));
    assertFalse(this.gotSeriesChangeEvent);
    series.setMaximumItemAge(1);
    assertEquals(1, series.getItemCount());
    assertEquals(0, series.getIndex(new Year(2001)));
    assertTrue(this.gotSeriesChangeEvent);
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Some checks for the removeAgedItems(long, boolean) method.
 *///from www.j  a v a 2  s.  c om
@Test
public void testRemoveAgedItems2() {
    long y2006 = 1157087372534L; // milliseconds somewhere in 2006
    TimeSeries series = new TimeSeries("Test Series", Year.class);
    series.addChangeListener(this);
    assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
    assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
    this.gotSeriesChangeEvent = false;

    // test empty series
    series.removeAgedItems(y2006, true);
    assertEquals(0, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test a series with 1 item
    series.add(new Year(2004), 1.0);
    series.setMaximumItemAge(1);
    this.gotSeriesChangeEvent = false;
    series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
    assertEquals(1, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);
    series.removeAgedItems(y2006, true);
    assertEquals(0, series.getItemCount());
    assertTrue(this.gotSeriesChangeEvent);

    // test a series with two items
    series.setMaximumItemAge(2);
    series.add(new Year(2003), 1.0);
    series.add(new Year(2005), 2.0);
    assertEquals(2, series.getItemCount());
    this.gotSeriesChangeEvent = false;
    assertEquals(2, series.getItemCount());

    series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
    assertEquals(2, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);
    series.removeAgedItems(y2006, true);
    assertEquals(1, series.getItemCount());
    assertTrue(this.gotSeriesChangeEvent);
}

From source file:info.financialecology.finance.utilities.datastruct.VersatileTimeSeriesCollection.java

/**
 * Ensure that all time series have identical time stamps. This uses the method {@code compareTo()} of
 * the class {@link RegularTimePeriod}. {@link RegularTimePeriod} is an abstract class subclassed
 * by classes {@code Day, FixedMillisecond, Hour, Millisecond, Minute, Month, Quarter, Second, Week, Year}.
 * //from   ww  w  . ja v a2  s  . co m
 * @return true if all time series in the collection have identical time stamps
 */
public Boolean checkConsistency() {

    int numTs = this.getSeriesCount();

    Assertion.assertOrKill(numTs > 0, "Cannot use method checkConsistency() for empty time series collection");

    if (numTs == 1)
        return true; // just one time series?

    TimeSeries baseTs = this.getSeries(0); // the base time series with which all others in this collection are compared

    for (int i = 1; i < this.getSeriesCount(); i++) {

        TimeSeries ts = this.getSeries(i);

        if (ts.getItemCount() != baseTs.getItemCount())
            return false; // different lengths?

        for (int t = 0; t < ts.getItemCount(); t++) // check all time stamps 
            if (ts.getTimePeriod(t).compareTo(baseTs.getTimePeriod(t)) != 0)
                return false;
    }

    return true;
}

From source file:org.mwc.cmap.xyplot.views.XYPlotView.java

@SuppressWarnings("deprecation")
private void fillThePlot(final String title, final String units, final formattingOperation theFormatter,
        final AbstractSeriesDataset dataset) {

    final StepControl _theStepper = null;

    // the working variables we rely on later
    _thePlotArea = null;/*from  w w  w. j  a  v a  2s.  c om*/
    ValueAxis xAxis = null;

    XYToolTipGenerator tooltipGenerator = null;

    // the y axis is common to hi & lo res. Format it here
    final NumberAxis yAxis = new NumberAxis(units);
    final Font tickFont = new Font("SansSerif", Font.PLAIN, 14);
    Font labelFont = new Font("SansSerif", Font.PLAIN, 16);
    yAxis.setLabelFont(labelFont);
    yAxis.setTickLabelFont(tickFont);

    // hmm, see if we are in hi-res mode. If we are, don't use a formatted
    // y-axis, just use the plain long microseconds
    // value
    if (HiResDate.inHiResProcessingMode()) {

        // final SimpleDateFormat _secFormat = new SimpleDateFormat("ss");

        // ok, simple enough for us...
        final NumberAxis nAxis = new NumberAxis("time (secs.micros)") {
            /**
             * 
             */
            private static final long serialVersionUID = 1L;

            // public String getTickLabel(double currentTickValue)
            // {
            // long time = (long) currentTickValue;
            // Date dtg = new HiResDate(0, time).getDate();
            // String res = _secFormat.format(dtg) + "."
            // + DebriefFormatDateTime.formatMicros(new HiResDate(0, time));
            // return res;
            // }
        };
        nAxis.setAutoRangeIncludesZero(false);
        xAxis = nAxis;

        // just show the raw data values
        tooltipGenerator = new StandardXYToolTipGenerator();
    } else {
        // create a date-formatting axis
        final DateAxis dAxis = new RelativeDateAxis();
        dAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits());
        xAxis = dAxis;

        // also create the date-knowledgable tooltip writer
        tooltipGenerator = new DatedToolTipGenerator();
    }

    xAxis.setTickLabelFont(tickFont);
    xAxis.setLabelFont(labelFont);

    // create the special stepper plot
    final ColourStandardXYItemRenderer theRenderer = new ColourStandardXYItemRenderer(tooltipGenerator, null,
            null);
    _thePlot = new StepperXYPlot(null, (RelativeDateAxis) xAxis, yAxis, _theStepper, theRenderer);
    theRenderer.setPlot(_thePlot);
    theRenderer.setStroke(new BasicStroke(3.0f));

    _thePlot.setRangeGridlineStroke(new BasicStroke(1f));
    _thePlot.setDomainGridlineStroke(new BasicStroke(1f));
    _thePlot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xAxis.setTickMarkStroke(new BasicStroke(1f));
    yAxis.setTickMarkStroke(new BasicStroke(1f));
    _thePlot.setOutlineStroke(new BasicStroke(2f));

    // loop through the datasets, setting the color of each series to the first
    // color in that series
    if (dataset instanceof TimeSeriesCollection) {
        Color seriesCol = null;
        final TimeSeriesCollection tsc = (TimeSeriesCollection) dataset;
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            final TimeSeries ts = tsc.getSeries(i);
            if (ts.getItemCount() > 0) {
                final TimeSeriesDataItem dataItem = ts.getDataItem(0);
                if (dataItem instanceof ColouredDataItem) {
                    final ColouredDataItem cd = (ColouredDataItem) dataItem;
                    seriesCol = cd.getColor();
                    _thePlot.getRenderer().setSeriesPaint(i, seriesCol);
                }
            }
        }
    }

    // apply any formatting for this choice
    if (theFormatter != null) {
        theFormatter.format(_thePlot);
    }

    boolean createLegend = dataset.getSeriesCount() > 1;
    _thePlotArea = new NewFormattedJFreeChart(title, null, _thePlot, createLegend, _theStepper);

    // set the color of the area surrounding the plot
    // - naah, don't bother. leave it in the application background color.
    _thePlotArea.setBackgroundPaint(Color.white);

    // ////////////////////////////////////////////////
    // put the holder into one of our special items
    // ////////////////////////////////////////////////
    _chartInPanel = new StepperChartPanel(_thePlotArea, true, _theStepper);

    // ok - we need to fire time-changes to the chart
    setupFiringChangesToChart();

    // format the chart
    _chartInPanel.setName(title);
    _chartInPanel.setMouseZoomable(true, true);

    // and insert into the composite
    _plotControl.setChart(_thePlotArea);

    // get the cross hairs ready
    _thePlot.setDomainCrosshairVisible(true);
    _thePlot.setRangeCrosshairVisible(true);
    _thePlot.setDomainCrosshairPaint(Color.GRAY);
    _thePlot.setRangeCrosshairPaint(Color.GRAY);
    _thePlot.setDomainCrosshairStroke(new BasicStroke(2));
    _thePlot.setRangeCrosshairStroke(new BasicStroke(2));

    // and the plot object to display the cross hair value
    _crosshairValueText = new XYTextAnnotation(" ", 0, 0);
    _crosshairValueText.setTextAnchor(TextAnchor.TOP_LEFT);
    _crosshairValueText.setFont(new Font("SansSerif", Font.BOLD, 15));
    _crosshairValueText.setPaint(Color.black);
    _crosshairValueText.setBackgroundPaint(Color.white);
    _thePlot.addAnnotation(_crosshairValueText);

    _thePlotArea.addChangeListener(new ChartChangeListener() {

        @Override
        public void chartChanged(ChartChangeEvent event) {
            if (_showSymbols.isShowSymbols() != _thePlotArea.isShowSymbols()) {
                _showSymbols.updateAction();
            }
        }
    });
    _showSymbols.updateAction();
    _thePlotArea.addProgressListener(new ChartProgressListener() {
        public void chartProgress(final ChartProgressEvent cpe) {
            if (cpe.getType() != ChartProgressEvent.DRAWING_FINISHED)
                return;

            // double-check our label is still in the right place
            final double xVal = _thePlot.getRangeAxis().getUpperBound();
            final double yVal = _thePlot.getDomainAxis().getLowerBound();

            boolean annotChanged = false;
            if (_crosshairValueText.getX() != yVal) {
                _crosshairValueText.setX(yVal);
                annotChanged = true;
            }
            if (_crosshairValueText.getY() != xVal) {
                _crosshairValueText.setY(xVal);
                annotChanged = true;
            }

            // and write the text
            final String numA = MWC.Utilities.TextFormatting.GeneralFormat
                    .formatOneDecimalPlace(_thePlot.getRangeCrosshairValue());
            final Date newDate = new Date((long) _thePlot.getDomainCrosshairValue());
            final SimpleDateFormat _df = new SimpleDateFormat("HHmm:ss");
            _df.setTimeZone(TimeZone.getTimeZone("GMT"));
            final String dateVal = _df.format(newDate);
            final String theMessage = " [" + dateVal + "," + numA + "]";
            if (!theMessage.equals(_crosshairValueText.getText())) {
                _crosshairValueText.setText(theMessage);
                annotChanged = true;
            }

            if (annotChanged) {
                _plotControl.getChart().setNotify(true);
            }
        }
    });

    // ////////////////////////////////////////////////////
    // put the time series into the plot
    // ////////////////////////////////////////////////////
    _thePlot.setDataset((XYDataset) dataset);
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java

/***********************************************************************************************
 * Dump the (partial) contents of each Series in an XYdatset.
 *
 * @param dump//from  w w  w . j  a v a  2s.co  m
 * @param calendar
 * @param dataset
 * @param dumprowcount
 * @param title
 */

public static void dumpXYDataset(final boolean dump, final Calendar calendar, final XYDataset dataset,
        final int dumprowcount, final String title) {
    final String SOURCE = "ChartHelper.dumpXYDataset() ";

    if (dump) {
        LOGGER.log(title);

        if ((dataset != null) && (dataset instanceof XYSeriesCollection)) {
            final XYSeriesCollection seriesCollection;

            seriesCollection = (XYSeriesCollection) dataset;

            LOGGER.log("XYSeriesCollection");
            LOGGER.log("    [series.count=" + seriesCollection.getSeriesCount() + "]");
            LOGGER.log("    [domain.lowerbound.interval.true="
                    + (long) seriesCollection.getDomainLowerBound(true) + "]");
            LOGGER.log("    [domain.lowerbound.interval.false="
                    + (long) seriesCollection.getDomainLowerBound(false) + "]");
            LOGGER.log("    [domain.upperbound.interval.true="
                    + (long) seriesCollection.getDomainUpperBound(true) + "]");
            LOGGER.log("    [domain.upperbound.interval.false="
                    + (long) seriesCollection.getDomainUpperBound(false) + "]");
            LOGGER.log("    [domain.order=" + seriesCollection.getDomainOrder() + "]");

            for (int intSeriesIndex = 0; intSeriesIndex < seriesCollection.getSeriesCount(); intSeriesIndex++) {
                final XYSeries xySeries;

                LOGGER.log("");
                LOGGER.log("    [xyseries.index=" + intSeriesIndex + "]");

                xySeries = seriesCollection.getSeries(intSeriesIndex);
                LOGGER.log("    [xyseries.itemcount=" + xySeries.getItemCount() + "]");
                LOGGER.log("    [xyseries.key=" + xySeries.getKey() + "]");
                LOGGER.log("    [xyseries.xmin=" + xySeries.getMinX() + "]");
                LOGGER.log("    [xyseries.xmax=" + xySeries.getMaxX() + "]");
                LOGGER.log("    [xyseries.ymin=" + xySeries.getMinY() + "]");
                LOGGER.log("    [xyseries.ymax=" + xySeries.getMaxY() + "]");
                LOGGER.log("    [xyseries.description=" + xySeries.getDescription() + "]");
                LOGGER.log("    [xyseries.autosort=" + xySeries.getAutoSort() + "]");
                LOGGER.log("    [xyseries.allowduplicatex=" + xySeries.getAllowDuplicateXValues() + "]");

                // Dump the first chunk
                for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount,
                        xySeries.getItemCount())); intItemIndex++) {
                    final XYDataItem item;

                    item = xySeries.getDataItem(intItemIndex);

                    LOGGER.log("        [item.index=" + intItemIndex + "] [item.x=" + item.getXValue()
                            + "] [item.y=" + item.getYValue() + "]");
                }

                LOGGER.log("    ...");

                // Dump the last chunk
                for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount,
                        xySeries.getItemCount())); intItemIndex++) {
                    final XYDataItem item;
                    final int intIndex;

                    intIndex = Math.max(0, xySeries.getItemCount() - dumprowcount) + intItemIndex;
                    item = xySeries.getDataItem(intIndex);

                    LOGGER.log("        [item.index=" + intIndex + "] [item.x=" + item.getXValue()
                            + "] [item.y=" + item.getYValue() + "]");
                }
            }
        } else if ((dataset != null) && (dataset instanceof TimeSeriesCollection)) {
            final TimeSeriesCollection seriesCollection;

            seriesCollection = (TimeSeriesCollection) dataset;

            LOGGER.log("TimeSeriesCollection");
            LOGGER.log("    [series.count=" + seriesCollection.getSeriesCount() + "]");
            LOGGER.log("    [domain.lowerbound.interval.true="
                    + (long) seriesCollection.getDomainLowerBound(true) + "]");
            LOGGER.log("    [domain.lowerbound.interval.false="
                    + (long) seriesCollection.getDomainLowerBound(false) + "]");
            LOGGER.log("    [domain.upperbound.interval.true="
                    + (long) seriesCollection.getDomainUpperBound(true) + "]");
            LOGGER.log("    [domain.upperbound.interval.false="
                    + (long) seriesCollection.getDomainUpperBound(false) + "]");
            LOGGER.log("    [domain.order=" + seriesCollection.getDomainOrder() + "]");

            for (int intSeriesIndex = 0; intSeriesIndex < seriesCollection.getSeriesCount(); intSeriesIndex++) {
                final TimeSeries timeSeries;

                LOGGER.log("");
                LOGGER.log("    [timeseries.index=" + intSeriesIndex + "]");

                timeSeries = seriesCollection.getSeries(intSeriesIndex);
                LOGGER.log("    [timeseries.itemcount=" + timeSeries.getItemCount() + "]");
                LOGGER.log("    [timeseries.key=" + timeSeries.getKey() + "]");
                LOGGER.log("    [timeseries.ymin=" + timeSeries.getMinY() + "]");
                LOGGER.log("    [timeseries.ymax=" + timeSeries.getMaxY() + "]");
                LOGGER.log("    [timeseries.domain=" + timeSeries.getDomainDescription() + "]");
                LOGGER.log("    [timeseries.range=" + timeSeries.getRangeDescription() + "]");
                LOGGER.log(
                        "    [timeseries.timeperiodclass=" + timeSeries.getTimePeriodClass().getName() + "]");

                for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount,
                        timeSeries.getItemCount())); intItemIndex++) {
                    final TimeSeriesDataItem item;

                    item = timeSeries.getDataItem(intItemIndex);

                    LOGGER.log("        [item.index=" + intItemIndex + "] [item.period.serialindex="
                            + item.getPeriod().getSerialIndex() + "] [item.period.firstmillis="
                            + item.getPeriod().getFirstMillisecond(calendar) + "] [item.value="
                            + item.getValue() + "]");
                }

                LOGGER.log("    ...");

                for (int intItemIndex = 0; intItemIndex < (Math.min(dumprowcount,
                        timeSeries.getItemCount())); intItemIndex++) {
                    final TimeSeriesDataItem item;
                    final int intIndex;

                    intIndex = Math.max(0, timeSeries.getItemCount() - dumprowcount) + intItemIndex;
                    item = timeSeries.getDataItem(intIndex);

                    LOGGER.log("        [item.index=" + intIndex + "] [item.period.serialindex="
                            + item.getPeriod().getSerialIndex() + "] [item.period.firstmillis="
                            + item.getPeriod().getFirstMillisecond(calendar) + "] [item.value="
                            + item.getValue() + "]");
                }
            }
        } else {
            LOGGER.error(SOURCE + "Unsupported XYDataset type");
        }
    }
}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartHelper.java

/***********************************************************************************************
 * Transform a Domain Slider value to an index into the List of specified data items,
 * taking account that the List may not fully occupy the Domain.
 *
 * Series_position   Left   Right//w ww .  j  a v  a2  s .c  o  m
 *        |
 *        |  xxx     start   -1
 *        |
 *        |xxx       start   start
 *        |
 *       xxx         index   index
 *        |
 *     xxx|          end     end
 *        |
 *   xxx  |          -1      end
 *        |
 *
 * @param domainslidermin
 * @param domainslidermax
 * @param domainslidervalue
 * @param domainsliderindex
 * @param domainlowerbound
 * @param domainupperbound
 * @param datasettype
 * @param calendar
 * @param series
 * @param debug
 *
 * @return int
 */

public static int transformDomainSliderValueToSeriesIndex(final int domainslidermin, final int domainslidermax,
        final int domainslidervalue, final int domainsliderindex, final double domainlowerbound,
        final double domainupperbound, final DatasetType datasettype, final Calendar calendar,
        final Series series, final boolean debug) {
    final String SOURCE = "ChartHelper.transformDomainSliderValueToSeriesIndex() ";
    final int intIndex;

    switch (datasettype) {
    case XY: {
        final XYSeries xySeries;
        final XYDataItem dataItemFirst;
        final XYDataItem dataItemLast;
        final double dblItemFirstX;
        final double dblItemLastX;
        final double dblItemLastFirstX;
        final double dblDomainSliderX;

        xySeries = (XYSeries) series;
        dataItemFirst = xySeries.getDataItem(0);
        dataItemLast = xySeries.getDataItem(xySeries.getItemCount() - 1);

        dblItemFirstX = dataItemFirst.getXValue();
        dblItemLastX = dataItemLast.getXValue();

        // Diagnostic only
        dblItemLastFirstX = dblItemLastX - dblItemFirstX;

        dblDomainSliderX = calculateDomainSliderX(domainslidermin, domainslidermax, domainslidervalue,
                domainlowerbound, domainupperbound);

        LOGGER.debug(debug,
                SOURCE + "\n[domain.slider.min=" + domainslidermin + "]\n[domain.slider.max=" + domainslidermax
                        + "]\n[domain.slider.value=" + domainslidervalue + "]\n[domain.slider.index="
                        + domainsliderindex + "]\n[domain.lowerbound=" + domainlowerbound
                        + "]\n[domain.upperbound=" + domainupperbound + "]\n[domain.slider.x="
                        + dblDomainSliderX + "]\n[lastfirstitem.x=" + dblItemLastFirstX + "]\n[firstitem.x="
                        + dblItemFirstX + "]\n[lastitem.x=" + dblItemLastX + "]\n[dataset.type="
                        + datasettype.getName() + "]\n[series.itemcount=" + series.getItemCount() + "]");

        if (domainsliderindex == INDEX_LEFT) {
            if (dblDomainSliderX <= dblItemFirstX) {
                intIndex = 0;
                //System.out.println("LEFT <=");
            } else if (dblDomainSliderX == dblItemLastX) {
                intIndex = xySeries.getItemCount() - 1;
                //System.out.println("LEFT ==");
            } else if (dblDomainSliderX > dblItemLastX) {
                intIndex = -1;
                //System.out.println("LEFT >");
            } else {
                intIndex = findXYDataItemIndexForX(dblDomainSliderX, xySeries);
                //System.out.println("LEFT index");
            }
        } else if (domainsliderindex == INDEX_RIGHT) {
            if (dblDomainSliderX < dblItemFirstX) {
                intIndex = -1;
                //System.out.println("RIGHT <");
            } else if (dblDomainSliderX == dblItemFirstX) {
                intIndex = 0;
                //System.out.println("RIGHT ==");
            } else if (dblDomainSliderX >= dblItemLastX) {
                intIndex = xySeries.getItemCount() - 1;
                //System.out.println("RIGHT >=");
            } else {
                intIndex = findXYDataItemIndexForX(dblDomainSliderX, xySeries);
                //System.out.println("RIGHT index");
            }
        } else {
            // Do nothing, an Error
            LOGGER.error(SOURCE + "Invalid Domain Slider [index=" + domainsliderindex + "]");
            intIndex = -1;
        }

        break;
    }

    case TIMESTAMPED: {
        final TimeSeries timeSeries;
        final TimeSeriesDataItem dataItemFirst;
        final TimeSeriesDataItem dataItemLast;
        final double dblItemFirstMillis;
        final double dblItemLastMillis;
        final double dblItemLastFirstMillis;
        final double dblDomainSliderMillis;

        timeSeries = (TimeSeries) series;
        dataItemFirst = timeSeries.getDataItem(0);
        dataItemLast = timeSeries.getDataItem(timeSeries.getItemCount() - 1);

        dblItemFirstMillis = dataItemFirst.getPeriod().getFirstMillisecond(calendar);
        dblItemLastMillis = dataItemLast.getPeriod().getLastMillisecond(calendar);

        // Diagnostic only
        dblItemLastFirstMillis = dblItemLastMillis - dblItemFirstMillis;

        dblDomainSliderMillis = calculateDomainSliderMillis(domainslidermin, domainslidermax, domainslidervalue,
                domainlowerbound, domainupperbound, calendar, debug);
        LOGGER.debug(debug,
                SOURCE + "]\n\n[domain.slider.index=" + domainsliderindex + "]\n[domain.slider.value="
                        + domainslidervalue + "]\n[domain.slider.millis=" + (long) dblDomainSliderMillis

                        + "]\n\n[firstitem.millis.calendar=" + (long) dblItemFirstMillis
                        + "]\n[firstitem.millis.period=" + dataItemFirst.getPeriod().getFirstMillisecond()
                        + "]\n[lastitem.millis.calendar=" + (long) dblItemLastMillis
                        + "]\n[lastitem.millis.period=" + dataItemLast.getPeriod().getLastMillisecond()
                        + "]\n[lastfirstitem.millis=" + (long) dblItemLastFirstMillis

                        + "]\n\n[dataset.type=" + datasettype.getName() + "]\n[series.itemcount="
                        + series.getItemCount() + "]");

        if (domainsliderindex == INDEX_LEFT) {
            if (dblDomainSliderMillis <= dblItemFirstMillis) {
                intIndex = 0;
                LOGGER.debug(debug, SOURCE + "LEFT(slider) <= FIRST(calendar)");
            } else if (dblDomainSliderMillis == dblItemLastMillis) {
                intIndex = timeSeries.getItemCount() - 1;
                LOGGER.debug(debug, SOURCE + "LEFT(slider) == LAST(calendar)");
            } else if (dblDomainSliderMillis > dblItemLastMillis) {
                intIndex = -1;
                LOGGER.debug(debug, SOURCE + "LEFT(slider) > LAST(calendar)");
            } else {
                intIndex = findTimeSeriesIndexForMillis(dblDomainSliderMillis, timeSeries, calendar);
                LOGGER.debug(debug, SOURCE + "LEFT ok");
            }
        } else if (domainsliderindex == INDEX_RIGHT) {
            if (dblDomainSliderMillis < dblItemFirstMillis) {
                intIndex = -1;
                LOGGER.debug(debug, SOURCE + "RIGHT(slider) < FIRST(calendar)");
            } else if (dblDomainSliderMillis == dblItemFirstMillis) {
                intIndex = 0;
                LOGGER.debug(debug, SOURCE + "RIGHT(slider) == FIRST(calendar)");
            } else if (dblDomainSliderMillis >= dblItemLastMillis) {
                intIndex = timeSeries.getItemCount() - 1;
                LOGGER.debug(debug, SOURCE + "RIGHT(slider) >= LAST(calendar)");
            } else {
                intIndex = findTimeSeriesIndexForMillis(dblDomainSliderMillis, timeSeries, calendar);
                LOGGER.debug(debug, SOURCE + "RIGHT(slider) ok");
            }
        } else {
            // Do nothing, an Error
            LOGGER.error(SOURCE + "Invalid Domain Slider [domainslider.index=" + domainsliderindex + "]");
            intIndex = -1;
        }

        break;
    }

    default: {
        // Do nothing, an Error
        LOGGER.error(SOURCE + "Invalid DatasetType [type=" + datasettype.getName() + "]");
        intIndex = -1;
    }
    }

    LOGGER.debug(debug,
            SOURCE + "[series.item.index=" + intIndex + "] [series.item.count=" + series.getItemCount() + "]");
    LOGGER.debug(debug, Logger.CONSOLE_SEPARATOR_MINOR);

    return (intIndex);
}