Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

PCalDayInfo net::sf::linuxorg::pcal::engine::Engine::getDayInfoEstimated ( final Date  date,
Date  last_date 
) [inline, private]

This inner method evaluated the date information for the dates beyond the recorded periods

Parameters:
date- the date being analyzed
last_date- the last recorded date
Returns:
the day info record or NULL if no data available

Definition at line 223 of file Engine.java.

References avgLength, dateDiff(), dateTypes, net::sf::linuxorg::pcal::PCalDayInfo::day_num, net::sf::linuxorg::pcal::PCalDayInfo::estimate, net::sf::linuxorg::pcal::engine::DayInfoRecordsFactory::getDay1Info(), net::sf::linuxorg::pcal::engine::DayInfoRecordsFactory::getNonFertileDayInfo(), getPeriodStartDate(), net::sf::linuxorg::pcal::engine::DayInfoRecordsFactory::getPregnancyDayInfo(), and periodsCount.

Referenced by getDayInfo().

                                                                               {
            PCalDayInfo info;

            // the day parameters should be predicted
            int day_num = dateDiff(last_date, date);
            int last_date_type = dateTypes.get(last_date);

            if(last_date_type == PCAL_TYPE_OVULATION) {
                  if(periodsCount == 0) {
                        // There is nothing we can say about this day
                        return null;
                  }

                  Date periodStartDate = getPeriodStartDate(last_date, false);
                  if(periodStartDate == null) {
                        // can really say nothing since no adequate period start record found
                        return null;
                  }

                  day_num = dateDiff(periodStartDate, date);
                  if(day_num < avgLength) {
                        // the date in question is after the ovulation but still within a single period
                        // with the last recorded ovulation date - this day is definitely not fertile
                        info = DayInfoRecordsFactory.getNonFertileDayInfo(day_num);
                        info.estimate = true;
                        return info;
                  } else {
                        // in this case, the ovulation record has no influence on the date in question
                        // let's proceed with the regular estimation process
                        last_date_type = dateTypes.get(periodStartDate);
                  }
            }

            if(last_date_type == PCAL_TYPE_MENS) {
                  if(periodsCount == 0) {
                        // There is nothing we can say about this day
                        return null;
                  }

                  // the cycle number is calculated by the average cycle length but
                  // the fertility will be 
                  if(avgLength!=0)
                        day_num %= avgLength;

                  if(day_num == 0) {
                        // most probably this will be a day 1
                        info = DayInfoRecordsFactory.getDay1Info(PCAL_TYPE_MENS);                     
                  } else {
                        info = DayInfoRecordsFactory.getNonFertileDayInfo(day_num);
                        // this is a day after the last recorded period start
                        if(recordedOvulations >12 ) {
                              // use the average ovulation date as a basis to predict fertility
                              info.fertile = (info.day_num >= (minOvulationDayNum - 9 - enginePreferences.bufferDays)) 
                              && (info.day_num <= (maxOvulationDayNum + enginePreferences.bufferDays));
                        } else {
                              // the number of non-fertile days at the beginning of the cycle is 
                              // considered as the minimum cycle length - 20
                              info.fertile = (info.day_num >= (minLength - 20 - enginePreferences.bufferDays)) 
                              && (info.day_num < (maxLength - 11 + enginePreferences.bufferDays));
                        }
                        info.badFeel = (info.day_num<=enginePreferences.badFeelDaysAfter)||
                        ((avgLength-info.day_num)<=enginePreferences.badFeelDaysBefore);
                  }
                  //info = DayInfoRecordsFactory.getNonFertileDayInfo(-1);
            } else 
                  if(last_date_type == PCAL_TYPE_PREGNANCY) {
                        if(day_num < REGULAR_PREGNANCY_DAYS) {
                              info = DayInfoRecordsFactory.getPregnancyDayInfo(day_num);
                        } else
                              if(day_num == REGULAR_PREGNANCY_DAYS) {
                                    info = DayInfoRecordsFactory.getDay1Info(PCAL_TYPE_BIRTH);
                              } else {
                                    // this is a day after the normal pregnancy period
                                    // know nothing
                                    info = DayInfoRecordsFactory.getNonFertileDayInfo(-1);
                              }
                  } else {
                        // know nothing
                        info = DayInfoRecordsFactory.getNonFertileDayInfo(-1);                        
                  }
            info.estimate = true;
            return info;
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index