001/* =========================================================== 002 * JFreeChart : a free chart library for the Java(tm) platform 003 * =========================================================== 004 * 005 * (C) Copyright 2000-2020, by Object Refinery Limited and Contributors. 006 * 007 * Project Info: http://www.jfree.org/jfreechart/index.html 008 * 009 * This library is free software; you can redistribute it and/or modify it 010 * under the terms of the GNU Lesser General Public License as published by 011 * the Free Software Foundation; either version 2.1 of the License, or 012 * (at your option) any later version. 013 * 014 * This library is distributed in the hope that it will be useful, but 015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 017 * License for more details. 018 * 019 * You should have received a copy of the GNU Lesser General Public 020 * License along with this library; if not, write to the Free Software 021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 022 * USA. 023 * 024 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 025 * Other names may be trademarks of their respective owners.] 026 * 027 * ------------------------- 028 * TimeSeriesCollection.java 029 * ------------------------- 030 * (C) Copyright 2001-2016, by Object Refinery Limited. 031 * 032 * Original Author: David Gilbert (for Object Refinery Limited); 033 * Contributor(s): -; 034 * 035 * Changes 036 * ------- 037 * 11-Oct-2001 : Version 1 (DG); 038 * 18-Oct-2001 : Added implementation of IntervalXYDataSource so that bar plots 039 * (using numerical axes) can be plotted from time series 040 * data (DG); 041 * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); 042 * 15-Nov-2001 : Added getSeries() method. Changed name from TimeSeriesDataset 043 * to TimeSeriesCollection (DG); 044 * 07-Dec-2001 : TimeSeries --> BasicTimeSeries (DG); 045 * 01-Mar-2002 : Added a time zone offset attribute, to enable fast calculation 046 * of the time period start and end values (DG); 047 * 29-Mar-2002 : The collection now registers itself with all the time series 048 * objects as a SeriesChangeListener. Removed redundant 049 * calculateZoneOffset method (DG); 050 * 06-Jun-2002 : Added a setting to control whether the x-value supplied in the 051 * getXValue() method comes from the START, MIDDLE, or END of the 052 * time period. This is a workaround for JFreeChart, where the 053 * current date axis always labels the start of a time 054 * period (DG); 055 * 24-Jun-2002 : Removed unnecessary import (DG); 056 * 24-Aug-2002 : Implemented DomainInfo interface, and added the 057 * DomainIsPointsInTime flag (DG); 058 * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); 059 * 16-Oct-2002 : Added remove methods (DG); 060 * 10-Jan-2003 : Changed method names in RegularTimePeriod class (DG); 061 * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented 062 * Serializable (DG); 063 * 04-Sep-2003 : Added getSeries(String) method (DG); 064 * 15-Sep-2003 : Added a removeAllSeries() method to match 065 * XYSeriesCollection (DG); 066 * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); 067 * 15-Jul-2004 : Switched getX() with getXValue() and getY() with 068 * getYValue() (DG); 069 * 06-Oct-2004 : Updated for changed in DomainInfo interface (DG); 070 * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 071 * release (DG); 072 * 28-Mar-2005 : Fixed bug in getSeries(int) method (1170825) (DG); 073 * ------------- JFREECHART 1.0.x --------------------------------------------- 074 * 13-Dec-2005 : Deprecated the 'domainIsPointsInTime' flag as it is 075 * redundant. Fixes bug 1243050 (DG); 076 * 04-May-2007 : Override getDomainOrder() to indicate that items are sorted 077 * by x-value (ascending) (DG); 078 * 08-May-2007 : Added indexOf(TimeSeries) method (DG); 079 * 18-Jan-2008 : Changed getSeries(String) to getSeries(Comparable) (DG); 080 * 19-May-2009 : Implemented XYDomainInfo (DG); 081 * 26-May-2009 : Implemented XYRangeInfo (DG); 082 * 09-Jun-2009 : Apply some short-cuts to series value lookups (DG); 083 * 26-Jun-2009 : Fixed clone() (DG); 084 * 08-Jan-2012 : Fixed getRangeBounds() method (bug 3445507) (DG); 085 * 02-Jul-2013 : Use ParamChecks (DG); 086 * 087 */ 088 089package org.jfree.data.time; 090 091import java.beans.PropertyChangeEvent; 092import java.beans.PropertyVetoException; 093import java.beans.VetoableChangeListener; 094import java.io.Serializable; 095import java.util.ArrayList; 096import java.util.Calendar; 097import java.util.Collections; 098import java.util.Iterator; 099import java.util.List; 100import java.util.TimeZone; 101import org.jfree.chart.util.ObjectUtils; 102import org.jfree.chart.util.Args; 103 104import org.jfree.data.DomainInfo; 105import org.jfree.data.DomainOrder; 106import org.jfree.data.Range; 107import org.jfree.data.general.DatasetChangeEvent; 108import org.jfree.data.general.Series; 109import org.jfree.data.xy.AbstractIntervalXYDataset; 110import org.jfree.data.xy.IntervalXYDataset; 111import org.jfree.data.xy.XYDataset; 112import org.jfree.data.xy.XYDomainInfo; 113import org.jfree.data.xy.XYRangeInfo; 114 115/** 116 * A collection of time series objects. This class implements the 117 * {@link XYDataset} interface, as well as the extended 118 * {@link IntervalXYDataset} interface. This makes it a convenient dataset for 119 * use with the {@link org.jfree.chart.plot.XYPlot} class. 120 */ 121public class TimeSeriesCollection extends AbstractIntervalXYDataset 122 implements XYDataset, IntervalXYDataset, DomainInfo, XYDomainInfo, 123 XYRangeInfo, VetoableChangeListener, Serializable { 124 125 /** For serialization. */ 126 private static final long serialVersionUID = 834149929022371137L; 127 128 /** Storage for the time series. */ 129 private List data; 130 131 /** A working calendar (to recycle) */ 132 private Calendar workingCalendar; 133 134 /** 135 * The point within each time period that is used for the X value when this 136 * collection is used as an {@link org.jfree.data.xy.XYDataset}. This can 137 * be the start, middle or end of the time period. 138 */ 139 private TimePeriodAnchor xPosition; 140 141 /** 142 * Constructs an empty dataset, tied to the default timezone. 143 */ 144 public TimeSeriesCollection() { 145 this(null, TimeZone.getDefault()); 146 } 147 148 /** 149 * Constructs an empty dataset, tied to a specific timezone. 150 * 151 * @param zone the timezone ({@code null} permitted, will use 152 * {@code TimeZone.getDefault()} in that case). 153 */ 154 public TimeSeriesCollection(TimeZone zone) { 155 // FIXME: need a locale as well as a timezone 156 this(null, zone); 157 } 158 159 /** 160 * Constructs a dataset containing a single series (more can be added), 161 * tied to the default timezone. 162 * 163 * @param series the series ({@code null} permitted). 164 */ 165 public TimeSeriesCollection(TimeSeries series) { 166 this(series, TimeZone.getDefault()); 167 } 168 169 /** 170 * Constructs a dataset containing a single series (more can be added), 171 * tied to a specific timezone. 172 * 173 * @param series a series to add to the collection ({@code null} 174 * permitted). 175 * @param zone the timezone ({@code null} permitted, will use 176 * {@code TimeZone.getDefault()} in that case). 177 */ 178 public TimeSeriesCollection(TimeSeries series, TimeZone zone) { 179 // FIXME: need a locale as well as a timezone 180 if (zone == null) { 181 zone = TimeZone.getDefault(); 182 } 183 this.workingCalendar = Calendar.getInstance(zone); 184 this.data = new ArrayList(); 185 if (series != null) { 186 this.data.add(series); 187 series.addChangeListener(this); 188 } 189 this.xPosition = TimePeriodAnchor.START; 190 } 191 192 /** 193 * Returns the order of the domain values in this dataset. 194 * 195 * @return {@link DomainOrder#ASCENDING} 196 */ 197 @Override 198 public DomainOrder getDomainOrder() { 199 return DomainOrder.ASCENDING; 200 } 201 202 /** 203 * Returns the position within each time period that is used for the X 204 * value when the collection is used as an 205 * {@link org.jfree.data.xy.XYDataset}. 206 * 207 * @return The anchor position (never {@code null}). 208 */ 209 public TimePeriodAnchor getXPosition() { 210 return this.xPosition; 211 } 212 213 /** 214 * Sets the position within each time period that is used for the X values 215 * when the collection is used as an {@link XYDataset}, then sends a 216 * {@link DatasetChangeEvent} is sent to all registered listeners. 217 * 218 * @param anchor the anchor position ({@code null} not permitted). 219 */ 220 public void setXPosition(TimePeriodAnchor anchor) { 221 Args.nullNotPermitted(anchor, "anchor"); 222 this.xPosition = anchor; 223 notifyListeners(new DatasetChangeEvent(this, this)); 224 } 225 226 /** 227 * Returns a list of all the series in the collection. 228 * 229 * @return The list (which is unmodifiable). 230 */ 231 public List getSeries() { 232 return Collections.unmodifiableList(this.data); 233 } 234 235 /** 236 * Returns the number of series in the collection. 237 * 238 * @return The series count. 239 */ 240 @Override 241 public int getSeriesCount() { 242 return this.data.size(); 243 } 244 245 /** 246 * Returns the index of the specified series, or -1 if that series is not 247 * present in the dataset. 248 * 249 * @param series the series ({@code null} not permitted). 250 * 251 * @return The series index. 252 * 253 * @since 1.0.6 254 */ 255 public int indexOf(TimeSeries series) { 256 Args.nullNotPermitted(series, "series"); 257 return this.data.indexOf(series); 258 } 259 260 /** 261 * Returns a series. 262 * 263 * @param series the index of the series (zero-based). 264 * 265 * @return The series. 266 */ 267 public TimeSeries getSeries(int series) { 268 if ((series < 0) || (series >= getSeriesCount())) { 269 throw new IllegalArgumentException( 270 "The 'series' argument is out of bounds (" + series + ")."); 271 } 272 return (TimeSeries) this.data.get(series); 273 } 274 275 /** 276 * Returns the series with the specified key, or {@code null} if 277 * there is no such series. 278 * 279 * @param key the series key ({@code null} permitted). 280 * 281 * @return The series with the given key. 282 */ 283 public TimeSeries getSeries(Comparable key) { 284 TimeSeries result = null; 285 Iterator iterator = this.data.iterator(); 286 while (iterator.hasNext()) { 287 TimeSeries series = (TimeSeries) iterator.next(); 288 Comparable k = series.getKey(); 289 if (k != null && k.equals(key)) { 290 result = series; 291 } 292 } 293 return result; 294 } 295 296 /** 297 * Returns the key for a series. 298 * 299 * @param series the index of the series (zero-based). 300 * 301 * @return The key for a series. 302 */ 303 @Override 304 public Comparable getSeriesKey(int series) { 305 // check arguments...delegated 306 // fetch the series name... 307 return getSeries(series).getKey(); 308 } 309 310 /** 311 * Returns the index of the series with the specified key, or -1 if no 312 * series has that key. 313 * 314 * @param key the key ({@code null} not permitted). 315 * 316 * @return The index. 317 * 318 * @since 1.0.17 319 */ 320 public int getSeriesIndex(Comparable key) { 321 Args.nullNotPermitted(key, "key"); 322 int seriesCount = getSeriesCount(); 323 for (int i = 0; i < seriesCount; i++) { 324 TimeSeries series = (TimeSeries) this.data.get(i); 325 if (key.equals(series.getKey())) { 326 return i; 327 } 328 } 329 return -1; 330 } 331 332 /** 333 * Adds a series to the collection and sends a {@link DatasetChangeEvent} to 334 * all registered listeners. 335 * 336 * @param series the series ({@code null} not permitted). 337 */ 338 public void addSeries(TimeSeries series) { 339 Args.nullNotPermitted(series, "series"); 340 this.data.add(series); 341 series.addChangeListener(this); 342 series.addVetoableChangeListener(this); 343 fireDatasetChanged(); 344 } 345 346 /** 347 * Removes the specified series from the collection and sends a 348 * {@link DatasetChangeEvent} to all registered listeners. 349 * 350 * @param series the series ({@code null} not permitted). 351 */ 352 public void removeSeries(TimeSeries series) { 353 Args.nullNotPermitted(series, "series"); 354 this.data.remove(series); 355 series.removeChangeListener(this); 356 series.removeVetoableChangeListener(this); 357 fireDatasetChanged(); 358 } 359 360 /** 361 * Removes a series from the collection. 362 * 363 * @param index the series index (zero-based). 364 */ 365 public void removeSeries(int index) { 366 TimeSeries series = getSeries(index); 367 if (series != null) { 368 removeSeries(series); 369 } 370 } 371 372 /** 373 * Removes all the series from the collection and sends a 374 * {@link DatasetChangeEvent} to all registered listeners. 375 */ 376 public void removeAllSeries() { 377 378 // deregister the collection as a change listener to each series in the 379 // collection 380 for (int i = 0; i < this.data.size(); i++) { 381 TimeSeries series = (TimeSeries) this.data.get(i); 382 series.removeChangeListener(this); 383 series.removeVetoableChangeListener(this); 384 } 385 386 // remove all the series from the collection and notify listeners. 387 this.data.clear(); 388 fireDatasetChanged(); 389 390 } 391 392 /** 393 * Returns the number of items in the specified series. This method is 394 * provided for convenience. 395 * 396 * @param series the series index (zero-based). 397 * 398 * @return The item count. 399 */ 400 @Override 401 public int getItemCount(int series) { 402 return getSeries(series).getItemCount(); 403 } 404 405 /** 406 * Returns the x-value (as a double primitive) for an item within a series. 407 * 408 * @param series the series (zero-based index). 409 * @param item the item (zero-based index). 410 * 411 * @return The x-value. 412 */ 413 @Override 414 public double getXValue(int series, int item) { 415 TimeSeries s = (TimeSeries) this.data.get(series); 416 RegularTimePeriod period = s.getTimePeriod(item); 417 return getX(period); 418 } 419 420 /** 421 * Returns the x-value for the specified series and item. 422 * 423 * @param series the series (zero-based index). 424 * @param item the item (zero-based index). 425 * 426 * @return The value. 427 */ 428 @Override 429 public Number getX(int series, int item) { 430 TimeSeries ts = (TimeSeries) this.data.get(series); 431 RegularTimePeriod period = ts.getTimePeriod(item); 432 return getX(period); 433 } 434 435 /** 436 * Returns the x-value for a time period. 437 * 438 * @param period the time period ({@code null} not permitted). 439 * 440 * @return The x-value. 441 */ 442 protected synchronized long getX(RegularTimePeriod period) { 443 long result = 0L; 444 if (this.xPosition == TimePeriodAnchor.START) { 445 result = period.getFirstMillisecond(this.workingCalendar); 446 } 447 else if (this.xPosition == TimePeriodAnchor.MIDDLE) { 448 result = period.getMiddleMillisecond(this.workingCalendar); 449 } 450 else if (this.xPosition == TimePeriodAnchor.END) { 451 result = period.getLastMillisecond(this.workingCalendar); 452 } 453 return result; 454 } 455 456 /** 457 * Returns the starting X value for the specified series and item. 458 * 459 * @param series the series (zero-based index). 460 * @param item the item (zero-based index). 461 * 462 * @return The value. 463 */ 464 @Override 465 public synchronized Number getStartX(int series, int item) { 466 TimeSeries ts = (TimeSeries) this.data.get(series); 467 return ts.getTimePeriod(item).getFirstMillisecond(this.workingCalendar); 468 } 469 470 /** 471 * Returns the ending X value for the specified series and item. 472 * 473 * @param series The series (zero-based index). 474 * @param item The item (zero-based index). 475 * 476 * @return The value. 477 */ 478 @Override 479 public synchronized Number getEndX(int series, int item) { 480 TimeSeries ts = (TimeSeries) this.data.get(series); 481 return ts.getTimePeriod(item).getLastMillisecond(this.workingCalendar); 482 } 483 484 /** 485 * Returns the y-value for the specified series and item. 486 * 487 * @param series the series (zero-based index). 488 * @param item the item (zero-based index). 489 * 490 * @return The value (possibly {@code null}). 491 */ 492 @Override 493 public Number getY(int series, int item) { 494 TimeSeries ts = (TimeSeries) this.data.get(series); 495 return ts.getValue(item); 496 } 497 498 /** 499 * Returns the starting Y value for the specified series and item. 500 * 501 * @param series the series (zero-based index). 502 * @param item the item (zero-based index). 503 * 504 * @return The value (possibly {@code null}). 505 */ 506 @Override 507 public Number getStartY(int series, int item) { 508 return getY(series, item); 509 } 510 511 /** 512 * Returns the ending Y value for the specified series and item. 513 * 514 * @param series te series (zero-based index). 515 * @param item the item (zero-based index). 516 * 517 * @return The value (possibly {@code null}). 518 */ 519 @Override 520 public Number getEndY(int series, int item) { 521 return getY(series, item); 522 } 523 524 525 /** 526 * Returns the indices of the two data items surrounding a particular 527 * millisecond value. 528 * 529 * @param series the series index. 530 * @param milliseconds the time. 531 * 532 * @return An array containing the (two) indices of the items surrounding 533 * the time. 534 */ 535 public int[] getSurroundingItems(int series, long milliseconds) { 536 int[] result = new int[] {-1, -1}; 537 TimeSeries timeSeries = getSeries(series); 538 for (int i = 0; i < timeSeries.getItemCount(); i++) { 539 Number x = getX(series, i); 540 long m = x.longValue(); 541 if (m <= milliseconds) { 542 result[0] = i; 543 } 544 if (m >= milliseconds) { 545 result[1] = i; 546 break; 547 } 548 } 549 return result; 550 } 551 552 /** 553 * Returns the minimum x-value in the dataset. 554 * 555 * @param includeInterval a flag that determines whether or not the 556 * x-interval is taken into account. 557 * 558 * @return The minimum value. 559 */ 560 @Override 561 public double getDomainLowerBound(boolean includeInterval) { 562 double result = Double.NaN; 563 Range r = getDomainBounds(includeInterval); 564 if (r != null) { 565 result = r.getLowerBound(); 566 } 567 return result; 568 } 569 570 /** 571 * Returns the maximum x-value in the dataset. 572 * 573 * @param includeInterval a flag that determines whether or not the 574 * x-interval is taken into account. 575 * 576 * @return The maximum value. 577 */ 578 @Override 579 public double getDomainUpperBound(boolean includeInterval) { 580 double result = Double.NaN; 581 Range r = getDomainBounds(includeInterval); 582 if (r != null) { 583 result = r.getUpperBound(); 584 } 585 return result; 586 } 587 588 /** 589 * Returns the range of the values in this dataset's domain. 590 * 591 * @param includeInterval a flag that determines whether or not the 592 * x-interval is taken into account. 593 * 594 * @return The range. 595 */ 596 @Override 597 public Range getDomainBounds(boolean includeInterval) { 598 Range result = null; 599 Iterator iterator = this.data.iterator(); 600 while (iterator.hasNext()) { 601 TimeSeries series = (TimeSeries) iterator.next(); 602 int count = series.getItemCount(); 603 if (count > 0) { 604 RegularTimePeriod start = series.getTimePeriod(0); 605 RegularTimePeriod end = series.getTimePeriod(count - 1); 606 Range temp; 607 if (!includeInterval) { 608 temp = new Range(getX(start), getX(end)); 609 } 610 else { 611 temp = new Range( 612 start.getFirstMillisecond(this.workingCalendar), 613 end.getLastMillisecond(this.workingCalendar)); 614 } 615 result = Range.combine(result, temp); 616 } 617 } 618 return result; 619 } 620 621 /** 622 * Returns the bounds of the domain values for the specified series. 623 * 624 * @param visibleSeriesKeys a list of keys for the visible series. 625 * @param includeInterval include the x-interval? 626 * 627 * @return A range. 628 * 629 * @since 1.0.13 630 */ 631 @Override 632 public Range getDomainBounds(List visibleSeriesKeys, 633 boolean includeInterval) { 634 Range result = null; 635 Iterator iterator = visibleSeriesKeys.iterator(); 636 while (iterator.hasNext()) { 637 Comparable seriesKey = (Comparable) iterator.next(); 638 TimeSeries series = getSeries(seriesKey); 639 int count = series.getItemCount(); 640 if (count > 0) { 641 RegularTimePeriod start = series.getTimePeriod(0); 642 RegularTimePeriod end = series.getTimePeriod(count - 1); 643 Range temp; 644 if (!includeInterval) { 645 temp = new Range(getX(start), getX(end)); 646 } 647 else { 648 temp = new Range( 649 start.getFirstMillisecond(this.workingCalendar), 650 end.getLastMillisecond(this.workingCalendar)); 651 } 652 result = Range.combine(result, temp); 653 } 654 } 655 return result; 656 } 657 658 /** 659 * Returns the bounds for the y-values in the dataset. 660 * 661 * @param includeInterval ignored for this dataset. 662 * 663 * @return The range of value in the dataset (possibly {@code null}). 664 * 665 * @since 1.0.15 666 */ 667 public Range getRangeBounds(boolean includeInterval) { 668 Range result = null; 669 Iterator iterator = this.data.iterator(); 670 while (iterator.hasNext()) { 671 TimeSeries series = (TimeSeries) iterator.next(); 672 Range r = new Range(series.getMinY(), series.getMaxY()); 673 result = Range.combineIgnoringNaN(result, r); 674 } 675 return result; 676 } 677 678 /** 679 * Returns the bounds for the y-values in the dataset. 680 * 681 * @param visibleSeriesKeys the visible series keys. 682 * @param xRange the x-range ({@code null} not permitted). 683 * @param includeInterval ignored. 684 * 685 * @return The bounds. 686 * 687 * @since 1.0.14 688 */ 689 @Override 690 public Range getRangeBounds(List visibleSeriesKeys, Range xRange, 691 boolean includeInterval) { 692 Range result = null; 693 Iterator iterator = visibleSeriesKeys.iterator(); 694 while (iterator.hasNext()) { 695 Comparable seriesKey = (Comparable) iterator.next(); 696 TimeSeries series = getSeries(seriesKey); 697 Range r = series.findValueRange(xRange, this.xPosition, 698 this.workingCalendar.getTimeZone()); 699 result = Range.combineIgnoringNaN(result, r); 700 } 701 return result; 702 } 703 704 /** 705 * Receives notification that the key for one of the series in the 706 * collection has changed, and vetos it if the key is already present in 707 * the collection. 708 * 709 * @param e the event. 710 * 711 * @since 1.0.17 712 */ 713 @Override 714 public void vetoableChange(PropertyChangeEvent e) 715 throws PropertyVetoException { 716 // if it is not the series name, then we have no interest 717 if (!"Key".equals(e.getPropertyName())) { 718 return; 719 } 720 721 // to be defensive, let's check that the source series does in fact 722 // belong to this collection 723 Series s = (Series) e.getSource(); 724 if (getSeriesIndex(s.getKey()) == -1) { 725 throw new IllegalStateException("Receiving events from a series " + 726 "that does not belong to this collection."); 727 } 728 // check if the new series name already exists for another series 729 Comparable key = (Comparable) e.getNewValue(); 730 if (getSeriesIndex(key) >= 0) { 731 throw new PropertyVetoException("Duplicate key2", e); 732 } 733 } 734 735 /** 736 * Tests this time series collection for equality with another object. 737 * 738 * @param obj the other object. 739 * 740 * @return A boolean. 741 */ 742 @Override 743 public boolean equals(Object obj) { 744 if (obj == this) { 745 return true; 746 } 747 if (!(obj instanceof TimeSeriesCollection)) { 748 return false; 749 } 750 TimeSeriesCollection that = (TimeSeriesCollection) obj; 751 if (this.xPosition != that.xPosition) { 752 return false; 753 } 754 if (!ObjectUtils.equal(this.data, that.data)) { 755 return false; 756 } 757 return true; 758 } 759 760 /** 761 * Returns a hash code value for the object. 762 * 763 * @return The hashcode 764 */ 765 @Override 766 public int hashCode() { 767 int result; 768 result = this.data.hashCode(); 769 result = 29 * result + (this.workingCalendar != null 770 ? this.workingCalendar.hashCode() : 0); 771 result = 29 * result + (this.xPosition != null 772 ? this.xPosition.hashCode() : 0); 773 return result; 774 } 775 776 /** 777 * Returns a clone of this time series collection. 778 * 779 * @return A clone. 780 * 781 * @throws java.lang.CloneNotSupportedException if there is a problem 782 * cloning. 783 */ 784 @Override 785 public Object clone() throws CloneNotSupportedException { 786 TimeSeriesCollection clone = (TimeSeriesCollection) super.clone(); 787 clone.data = (List) ObjectUtils.deepClone(this.data); 788 clone.workingCalendar = (Calendar) this.workingCalendar.clone(); 789 return clone; 790 } 791 792}