org.jfree.data.time.RegularTimePeriod Java Examples

The following examples show how to use org.jfree.data.time.RegularTimePeriod. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JFreeChartTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize a time seroes chart, restore it, and check for equality.
 */
@Test
public void testSerialization4() {

    RegularTimePeriod t = new Day();
    TimeSeries series = new TimeSeries("Series 1");
    series.add(t, 36.4);
    t = t.next();
    series.add(t, 63.5);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
            "Value", dataset);
    JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1);
    assertEquals(c1, c2);
}
 
Example #2
Source File: JFreeChartTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize a time seroes chart, restore it, and check for equality.
 */
@Test
public void testSerialization4() {

    RegularTimePeriod t = new Day();
    TimeSeries series = new TimeSeries("Series 1");
    series.add(t, 36.4);
    t = t.next();
    series.add(t, 63.5);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
            "Value", dataset);
    JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1);
    assertEquals(c1, c2);
}
 
Example #3
Source File: SymbolicXYItemLabelGenerator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
Example #4
Source File: SymbolicXYItemLabelGenerator.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
Example #5
Source File: SWTMultipleAxisDemo1.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a sample dataset.
 *
 * @param name  the dataset name.
 * @param base  the starting value.
 * @param start  the starting period.
 * @param count  the number of values to generate.
 *
 * @return The dataset.
 */
private static XYDataset createDataset(String name, double base,
                                       RegularTimePeriod start, int count) {

    TimeSeries series = new TimeSeries(name);
    RegularTimePeriod period = start;
    double value = base;
    for (int i = 0; i < count; i++) {
        series.add(period, value);
        period = period.next();
        value = value * (1 + (Math.random() - 0.495) / 10.0);
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    return dataset;

}
 
Example #6
Source File: SWTMultipleAxisDemo1.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a sample dataset.
 *
 * @param name  the dataset name.
 * @param base  the starting value.
 * @param start  the starting period.
 * @param count  the number of values to generate.
 *
 * @return The dataset.
 */
private static XYDataset createDataset(String name, double base,
                                       RegularTimePeriod start, int count) {

    TimeSeries series = new TimeSeries(name);
    RegularTimePeriod period = start;
    double value = base;
    for (int i = 0; i < count; i++) {
        series.add(period, value);
        period = period.next();
        value = value * (1 + (Math.random() - 0.495) / 10.0);
    }

    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    return dataset;

}
 
Example #7
Source File: JFreeChartTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize a time seroes chart, restore it, and check for equality.
 */
@Test
public void testSerialization4() {

    RegularTimePeriod t = new Day();
    TimeSeries series = new TimeSeries("Series 1");
    series.add(t, 36.4);
    t = t.next();
    series.add(t, 63.5);
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(series);

    JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date",
            "Value", dataset);
    JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1);
    assertEquals(c1, c2);
}
 
Example #8
Source File: SymbolicXYItemLabelGenerator.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
Example #9
Source File: SymbolicXYItemLabelGenerator.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
@Override
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
Example #10
Source File: OHLCSeriesCollection.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example #11
Source File: PeriodAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new axis.
 *
 * @param label  the axis label (<code>null</code> permitted).
 * @param first  the first time period in the axis range
 *               (<code>null</code> not permitted).
 * @param last  the last time period in the axis range
 *              (<code>null</code> not permitted).
 * @param timeZone  the time zone (<code>null</code> not permitted).
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @since 1.0.13
 */
public PeriodAxis(String label, RegularTimePeriod first,
        RegularTimePeriod last, TimeZone timeZone, Locale locale) {
    super(label, null);
    ParamChecks.nullNotPermitted(timeZone, "timeZone");
    ParamChecks.nullNotPermitted(locale, "locale");
    this.first = first;
    this.last = last;
    this.timeZone = timeZone;
    this.locale = locale;
    this.calendar = Calendar.getInstance(timeZone, locale);
    this.first.peg(this.calendar);
    this.last.peg(this.calendar);
    this.autoRangeTimePeriodClass = first.getClass();
    this.majorTickTimePeriodClass = first.getClass();
    this.minorTickMarksVisible = false;
    this.minorTickTimePeriodClass = RegularTimePeriod.downsize(
            this.majorTickTimePeriodClass);
    setAutoRange(true);
    this.labelInfo = new PeriodAxisLabelInfo[2];
    SimpleDateFormat df0 = new SimpleDateFormat("MMM", locale);
    df0.setTimeZone(timeZone);
    this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class, df0);
    SimpleDateFormat df1 = new SimpleDateFormat("yyyy", locale);
    df1.setTimeZone(timeZone);
    this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class, df1);
}
 
Example #12
Source File: OHLCSeries.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds a data item to the series.
 *
 * @param period  the period.
 * @param open  the open-value.
 * @param high  the high-value.
 * @param low  the low-value.
 * @param close  the close-value.
 */
public void add(RegularTimePeriod period, double open, double high,
        double low, double close) {
    if (getItemCount() > 0) {
        OHLCItem item0 = (OHLCItem) this.getDataItem(0);
        if (!period.getClass().equals(item0.getPeriod().getClass())) {
            throw new IllegalArgumentException(
                    "Can't mix RegularTimePeriod class types.");
        }
    }
    super.add(new OHLCItem(period, open, high, low, close), true);
}
 
Example #13
Source File: TimeSeriesLabelGenerator.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String generateLabel(XYDataset dataset, int series, int item)
{
	Comparable<?> seriesName = dataset.getSeriesKey(series);
	Map<RegularTimePeriod, String> labels = labelsMap.get(seriesName);
	if(labels != null)
	{
		return labels.get(((TimeSeriesCollection)dataset).getSeries(series).getTimePeriod(item));
	}
	return super.generateLabel( dataset, series, item );
}
 
Example #14
Source File: OHLCSeries.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds a data item to the series.
 *
 * @param period  the period.
 * @param open  the open-value.
 * @param high  the high-value.
 * @param low  the low-value.
 * @param close  the close-value.
 */
public void add(RegularTimePeriod period, double open, double high,
        double low, double close) {
    if (getItemCount() > 0) {
        OHLCItem item0 = (OHLCItem) this.getDataItem(0);
        if (!period.getClass().equals(item0.getPeriod().getClass())) {
            throw new IllegalArgumentException(
                    "Can't mix RegularTimePeriod class types.");
        }
    }
    super.add(new OHLCItem(period, open, high, low, close), true);
}
 
Example #15
Source File: SymbolicXYItemLabelGenerator.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
@Override
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
Example #16
Source File: TimeSeriesCollectionTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a time series for testing.
 *
 * @return A time series.
 */
private TimeSeries createSeries() {
    RegularTimePeriod t = new Day();
    TimeSeries series = new TimeSeries("Test");
    series.add(t, 1.0);
    t = t.next();
    series.add(t, 2.0);
    t = t.next();
    series.add(t, null);
    t = t.next();
    series.add(t, 4.0);
    return series;
}
 
Example #17
Source File: PeriodAxis.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the last time period in the axis range and sends an
 * {@link AxisChangeEvent} to all registered listeners.
 *
 * @param last  the time period (<code>null</code> not permitted).
 */
public void setLast(RegularTimePeriod last) {
    ParamChecks.nullNotPermitted(last, "last");
    this.last = last;
    this.last.peg(this.calendar);
    fireChangeEvent();
}
 
Example #18
Source File: OHLCSeriesCollection.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example #19
Source File: PeriodAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the first time period in the axis range and sends an
 * {@link AxisChangeEvent} to all registered listeners.
 *
 * @param first  the time period (<code>null</code> not permitted).
 */
public void setFirst(RegularTimePeriod first) {
    ParamChecks.nullNotPermitted(first, "first");
    this.first = first;
    this.first.peg(this.calendar);
    fireChangeEvent();
}
 
Example #20
Source File: SymbolicXYItemLabelGenerator.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
@Override
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
Example #21
Source File: OHLCSeries.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a data item to the series.
 *
 * @param period  the period.
 * @param open  the open-value.
 * @param high  the high-value.
 * @param low  the low-value.
 * @param close  the close-value.
 */
public void add(RegularTimePeriod period, double open, double high, 
        double low, double close) {
    if (getItemCount() > 0) {
        OHLCItem item0 = (OHLCItem) this.getDataItem(0);
        if (!period.getClass().equals(item0.getPeriod().getClass())) {
            throw new IllegalArgumentException(
                    "Can't mix RegularTimePeriod class types.");
        }
    }
    super.add(new OHLCItem(period, open, high, low, close), true);
}
 
Example #22
Source File: TimePeriodValuesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug report 1161329.
 */
public void test1161329() {
    TimePeriodValues tpv = new TimePeriodValues("Test");
    RegularTimePeriod t = new Day();
    tpv.add(t, 1.0);
    t = t.next();
    tpv.add(t, 2.0);
    tpv.delete(0, 1);
    assertEquals(0, tpv.getItemCount());
    tpv.add(t, 2.0);
    assertEquals(1, tpv.getItemCount());
}
 
Example #23
Source File: SymbolicXYItemLabelGenerator.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
@Override
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
Example #24
Source File: PeriodAxis.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the last time period in the axis range and sends an
 * {@link AxisChangeEvent} to all registered listeners.
 *
 * @param last  the time period (<code>null</code> not permitted).
 */
public void setLast(RegularTimePeriod last) {
    ParamChecks.nullNotPermitted(last, "last");
    this.last = last;
    this.last.peg(this.calendar);
    fireChangeEvent();
}
 
Example #25
Source File: OHLCSeries.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds a data item to the series.
 *
 * @param period  the period.
 * @param open  the open-value.
 * @param high  the high-value.
 * @param low  the low-value.
 * @param close  the close-value.
 */
public void add(RegularTimePeriod period, double open, double high,
        double low, double close) {
    if (getItemCount() > 0) {
        OHLCItem item0 = (OHLCItem) this.getDataItem(0);
        if (!period.getClass().equals(item0.getPeriod().getClass())) {
            throw new IllegalArgumentException(
                    "Can't mix RegularTimePeriod class types.");
        }
    }
    super.add(new OHLCItem(period, open, high, low, close), true);
}
 
Example #26
Source File: SymbolicXYItemLabelGenerator.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a tool tip text item for a particular item within a series.
 *
 * @param data  the dataset.
 * @param series  the series number (zero-based index).
 * @param item  the item number (zero-based index).
 *
 * @return The tool tip text (possibly <code>null</code>).
 */
@Override
public String generateToolTip(XYDataset data, int series, int item) {

    String xStr, yStr;
    if (data instanceof YisSymbolic) {
        yStr = ((YisSymbolic) data).getYSymbolicValue(series, item);
    }
    else {
        double y = data.getYValue(series, item);
        yStr = Double.toString(round(y, 2));
    }
    if (data instanceof XisSymbolic) {
        xStr = ((XisSymbolic) data).getXSymbolicValue(series, item);
    }
    else if (data instanceof TimeSeriesCollection) {
        RegularTimePeriod p
            = ((TimeSeriesCollection) data).getSeries(series)
                .getTimePeriod(item);
        xStr = p.toString();
    }
    else {
        double x = data.getXValue(series, item);
        xStr = Double.toString(round(x, 2));
    }
    return "X: " + xStr + ", Y: " + yStr;
}
 
Example #27
Source File: OHLCSeries.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a data item to the series.
 *
 * @param period  the period.
 * @param open  the open-value.
 * @param high  the high-value.
 * @param low  the low-value.
 * @param close  the close-value.
 */
public void add(RegularTimePeriod period, double open, double high,
        double low, double close) {
    if (getItemCount() > 0) {
        OHLCItem item0 = (OHLCItem) this.getDataItem(0);
        if (!period.getClass().equals(item0.getPeriod().getClass())) {
            throw new IllegalArgumentException(
                    "Can't mix RegularTimePeriod class types.");
        }
    }
    super.add(new OHLCItem(period, open, high, low, close), true);
}
 
Example #28
Source File: OHLCSeriesCollection.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the x-value for a time period.
 *
 * @param period  the time period (<code>null</code> not permitted).
 *
 * @return The x-value.
 */
protected synchronized long getX(RegularTimePeriod period) {
    long result = 0L;
    if (this.xPosition == TimePeriodAnchor.START) {
        result = period.getFirstMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {
        result = period.getMiddleMillisecond();
    }
    else if (this.xPosition == TimePeriodAnchor.END) {
        result = period.getLastMillisecond();
    }
    return result;
}
 
Example #29
Source File: TimeSeriesBuilder.java    From OpenForecast with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructs a new TimeSeriesBuilder that reads its input from the given
 * TimeSeries object. This builder defaults the of the independent, time
 * variable to be the class name of the RegularTimePeriod used in the
 * TimeSeries. For example, if a series of org.jfree.data.time.Day objects
 * are used, then the name of the independent variable will default to
 * "Day" (without the quotes).
 *
 * See the class description for more information.
 * @param timeSeries the TimeSeries object containing data to be used to
 * build the DataSet.
 * @throws IllegalArgumentException if the TimeSeries is empty.
 */
public TimeSeriesBuilder( TimeSeries timeSeries )
{
    if ( timeSeries.getItemCount() <= 0 )
        throw new IllegalArgumentException("TimeSeries cannot be empty.");
    
    this.timeSeries = timeSeries;
    
    // Use base name of TimePeriod class, as name of time variable
    RegularTimePeriod timePeriod = timeSeries.getTimePeriod(0);
    String name = timePeriod.getClass().getName();
    name = name.substring( name.lastIndexOf(".")+1 );
    addVariable( name );
}
 
Example #30
Source File: PeriodAxis.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the last time period in the axis range and sends an
 * {@link AxisChangeEvent} to all registered listeners.
 *
 * @param last  the time period (<code>null</code> not permitted).
 */
public void setLast(RegularTimePeriod last) {
    ParamChecks.nullNotPermitted(last, "last");
    this.last = last;
    this.last.peg(this.calendar);
    fireChangeEvent();
}