Ejemplo n.º 1
0
  /**
   * Creates two objects to improve performance of getValue(). The first object contains an array of
   * values so that the getValue() function can return values based on an index, rather than using
   * date calculations to extract the date from the Graphable. The second object contains a mapping
   * which maps the current date to an offset in the newly created array.
   */
  private void initialise() {
    dateOffsets = new HashMap();
    values = new ArrayList();

    TradingDate endDate = (TradingDate) graphable.getEndX();
    int offset = 0;

    for (TradingDate date = (TradingDate) graphable.getStartX();
        !date.after(endDate);
        date = date.next(1)) {
      values.add(graphable.getY(date));
      dateOffsets.put(date, new Integer(offset++));
    }
  }