コード例 #1
0
  public Interval locate(DataColumn column, Integer intervalIndex) {
    ColumnGroup columnGroup = column.getColumnGroup();
    Date columnMinDate = (Date) column.getMinValue();
    String type = column.getIntervalType();

    if (columnGroup == null) return null;
    if (columnMinDate == null) return null;
    if (type == null) return null;

    // Calculate the interval min. date.
    DateIntervalType intervalType = DateIntervalType.getByName(type);
    Calendar c = firstIntervalDate(intervalType, columnMinDate, columnGroup);
    nextIntervalDate(c, intervalType, intervalIndex);
    Date intervalMinDate = c.getTime();

    // Calculate the interval max. date.
    nextIntervalDate(c, intervalType, 1);
    Date intervalMaxDate = c.getTime();

    // Build & return the selected interval
    return new IntervalDateRange(intervalIndex, intervalType, intervalMinDate, intervalMaxDate);
  }
コード例 #2
0
  public IntervalList build(DataColumn dataColumn) {
    ColumnGroup columnGroup = dataColumn.getColumnGroup();
    Date minDate = (Date) dataColumn.getMinValue();
    Date maxDate = (Date) dataColumn.getMaxValue();

    IntervalDateRangeList results = new IntervalDateRangeList(columnGroup);
    if (minDate == null || maxDate == null) {
      return results;
    }
    DateIntervalType intervalType = DateIntervalType.getByName(dataColumn.getIntervalType());
    if (intervalType == null) {
      intervalType = DateIntervalType.YEAR;
    }
    Calendar c = firstIntervalDate(intervalType, minDate, columnGroup);
    int counter = 0;
    while (c.getTime().compareTo(maxDate) <= 0) {
      Date intervalMinDate = c.getTime();

      // Create the next interval
      nextIntervalDate(c, intervalType, 1);
      Date intervalMaxDate = c.getTime();
      IntervalDateRange interval =
          new IntervalDateRange(counter++, intervalType, intervalMinDate, intervalMaxDate);
      results.add(interval);
    }

    // Reverse intervals if requested
    boolean asc = columnGroup.isAscendingOrder();
    if (!asc) Collections.reverse(results);

    // Return the results
    results.setIntervalType(intervalType.toString());
    results.setMinValue(minDate);
    results.setMaxValue(maxDate);
    return results;
  }