public String getColumnText(Object element, int columnIndex) {
      TransactionPair<?> pair = (TransactionPair<?>) element;
      Transaction t = pair.getTransaction();

      switch (columnIndex) {
        case 0:
          return Values.Date.format(t.getDate());
        case 1:
          if (t instanceof AccountTransaction) return ((AccountTransaction) t).getType().toString();
          else if (t instanceof PortfolioTransaction)
            return ((PortfolioTransaction) t).getType().toString();
          return null;
        case 2:
          return Values.Share.format(t.getShares());
        case 3:
          if (model.isChangeTransactions() && t.getDate().before(model.getExDate())) {
            long shares = t.getShares() * model.getNewShares() / model.getOldShares();
            return Values.Share.format(shares);
          }
          return null;
        case 4:
          return pair.getOwner().toString();
        default:
          return null;
      }
    }
예제 #2
0
  private static void collectDatesAndValues(
      Date start,
      Date end,
      ClientSnapshot snapshotStart,
      ClientSnapshot snapshotEnd,
      List<Transaction> transactions,
      List<Date> dates,
      List<Double> values) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(start);
    dates.add(cal.getTime());
    values.add(-(snapshotStart.getAssets()) / Values.Amount.divider());

    for (Transaction t : transactions) {
      cal.setTime(t.getDate());
      dates.add(cal.getTime());

      if (t instanceof AccountTransaction) {
        AccountTransaction at = (AccountTransaction) t;
        long amount = at.getAmount();
        if (at.getType() == Type.DEPOSIT || at.getType() == Type.TRANSFER_IN) amount = -amount;
        values.add(amount / Values.Amount.divider());
      } else if (t instanceof PortfolioTransaction) {
        PortfolioTransaction pt = (PortfolioTransaction) t;

        long amount = pt.getAmount();
        if (pt.getType() == PortfolioTransaction.Type.DELIVERY_INBOUND
            || pt.getType() == PortfolioTransaction.Type.TRANSFER_IN) amount = -amount;
        values.add(amount / Values.Amount.divider());
      } else {
        throw new UnsupportedOperationException();
      }
    }

    cal.setTime(end);
    dates.add(cal.getTime());
    values.add(snapshotEnd.getAssets() / Values.Amount.divider());
  }
예제 #3
0
 @Override
 public int compare(Transaction t1, Transaction t2) {
   return t1.getDate().compareTo(t2.getDate());
 }