Beispiel #1
0
 private Date minimumDate() {
   if (firstStartDate == null) {
     Calendar calendar = Calendar.getInstance();
     calendar.add(Calendar.YEAR, -1);
     firstStartDate = DateFactory.midnithDate(calendar.getTime());
   }
   return firstStartDate;
 }
Beispiel #2
0
  public Stack<OnTheFlyRevesreCalcPeriod> splitForward(
      Date dateDeb, Date dateFin, Integer periodLength, int calendarTimeUnit) {

    Calendar dateDebCal = Calendar.getInstance();
    dateDebCal.setTime(DateFactory.midnithDate(dateDeb));

    Calendar dateFinCal = Calendar.getInstance();
    dateFinCal.setTime(DateFactory.midnithDate(dateFin));
    dateFinCal.add(Calendar.DAY_OF_YEAR, 1); // for exclusive subsets fix

    Stack<OnTheFlyRevesreCalcPeriod> retuneDates = new Stack<OnTheFlyRevesreCalcPeriod>();

    if (periodLength > 0) {

      Calendar slidingDateDebCal = Calendar.getInstance();
      slidingDateDebCal.setTime(dateDeb);

      // Add previous periods
      while (dateFinCal.getTime().after(slidingDateDebCal.getTime())) {

        Date pStartDate = slidingDateDebCal.getTime();
        if (calendarTimeUnit == Calendar.MONTH) {
          QuotationsFactories.getFactory().incrementDateLarge(slidingDateDebCal, periodLength);
        } else if (calendarTimeUnit == Calendar.DAY_OF_YEAR) {
          QuotationsFactories.getFactory().incrementDate(slidingDateDebCal, periodLength);
        } else {
          throw new InvalidParameterException("calendarTimeUnit : " + calendarTimeUnit);
        }
        Date pEndDate = slidingDateDebCal.getTime();

        if (pEndDate.before(dateFinCal.getTime())) {
          retuneDates.add(0, new OnTheFlyRevesreCalcPeriod(dateDeb, dateFin, pStartDate, pEndDate));
        } else { // End date reached
          retuneDates.add(
              0, new OnTheFlyRevesreCalcPeriod(dateDeb, dateFin, pStartDate, dateFinCal.getTime()));
          break;
        }
      }

    } else {
      retuneDates.add(new OnTheFlyRevesreCalcPeriod(dateDeb, dateFin, dateDeb, dateFin));
    }

    return retuneDates;
  }
Beispiel #3
0
  public ChartsComposite(Composite parent, int style, LogComposite logComposite) {
    super(parent, style);

    this.currentTabShareList = new ArrayList<SlidingPortfolioShare>();

    this.slidingEndDate = DateFactory.midnithDate(EventSignalConfig.getNewDate());
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.YEAR, -1);
    this.slidingStartDate = DateFactory.midnithDate(calendar.getTime());

    this.logComposite = logComposite;
    this.hightlitedEventModel = EventModel.getInstance(new RefreshChartHighlighted(), logComposite);

    this.chartedEvtDefsTrends = initChartedEvtDefsTrendsSet();
    this.chartedEvtDef = EventDefinition.ZERO;

    this.sliderSelection = false;

    this.stripedCloseFunction = new StripedCloseRelativeToStart(slidingStartDate, slidingEndDate);
    this.initGUI();
    chartDisplayStrategy = new ChartPerfDisplay(this);
  }
Beispiel #4
0
 // The marker has the last time stamp (milli since 1970) and hence is the last transaction for any
 // days
 public SortedSet<TransactionElement> headTransactionsTo(
     Date currentStartDate, Date currentEndDate) {
   if (currentStartDate == null || currentStartDate.equals(DateFactory.dateAtZero())) {
     return transactions.headSet(
         new TransactionElement(null, null, null, currentEndDate, null, null, null));
   } else {
     Calendar currentDateCal = Calendar.getInstance();
     currentDateCal.setTime(currentStartDate);
     currentDateCal.add(Calendar.DAY_OF_YEAR, -1);
     return transactions.subSet(
         new TransactionElement(null, null, null, currentDateCal.getTime(), null, null, null),
         new TransactionElement(null, null, null, currentEndDate, null, null, null));
   }
 }
Beispiel #5
0
  public Stack<OnTheFlyRevesreCalcPeriod> splitBackward(
      Date dateDeb, Date dateFin, Integer periodLength, int calendarTimeUnit) {

    Calendar dateDebCal = Calendar.getInstance();
    dateDebCal.setTime(DateFactory.midnithDate(dateDeb));

    Calendar dateFinCal = Calendar.getInstance();
    dateFinCal.setTime(DateFactory.midnithDate(dateFin));

    Stack<OnTheFlyRevesreCalcPeriod> retuneDates = new Stack<OnTheFlyRevesreCalcPeriod>();

    if (periodLength > 0) {

      Calendar slidingDateFinCal = Calendar.getInstance();
      slidingDateFinCal.setTime(dateFin);
      slidingDateFinCal.add(Calendar.DAY_OF_YEAR, 1); // for exclusive subsets fix

      // Add previous periods
      while (dateDebCal.getTime().before(slidingDateFinCal.getTime())) {

        Date pEndDate = slidingDateFinCal.getTime();
        if (calendarTimeUnit == Calendar.DAY_OF_YEAR) {
          QuotationsFactories.getFactory().incrementDate(slidingDateFinCal, -periodLength);
        } else {
          QuotationsFactories.getFactory().incrementDateLarge(slidingDateFinCal, -periodLength);
        }
        Date pStartDate = slidingDateFinCal.getTime();
        retuneDates.add(new OnTheFlyRevesreCalcPeriod(dateDeb, dateFin, pStartDate, pEndDate));
      }

    } else {

      retuneDates.add(new OnTheFlyRevesreCalcPeriod(dateDeb, dateFin, dateDeb, dateFin));
    }

    return retuneDates;
  }
Beispiel #6
0
  private void endSliderUpdate(Slider sliderEndDate, Label endDateLabel, Integer sliderValue) {

    Date maxDate = maxDate();
    Date minDate = minimumDate();
    Integer maxSlider = 100;
    Integer minSlider = 0;
    Integer perCentValue = sliderValue * 100 / (maxSlider - minSlider - sliderEndDate.getThumb());

    Long diffDate = (maxDate.getTime() - minDate.getTime()) / (1000 * 3600 * 24);
    Long nbDaySinceMin = perCentValue * diffDate / 100;
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(minDate);
    calendar.add(Calendar.DAY_OF_YEAR, nbDaySinceMin.intValue());
    slidingEndDate = DateFactory.midnithDate(calendar.getTime());

    endDateLabel.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(slidingEndDate));
    endDateLabel.setFont(MainGui.DEFAULTFONT);
  }
Beispiel #7
0
 private Date maxDate() {
   if (lastEndDate == null) {
     lastEndDate = DateFactory.midnithDate(EventSignalConfig.getNewDate());
   }
   return lastEndDate;
 }