Exemple #1
0
 public void changeStockListTo(StockList stocks) {
   this.stocks = stocks;
   this.fireTableDataChanged();
   state.clear();
   for (int row = 0; row < stocks.getStockList().size(); row++) {
     Stock stock = stocks.getStockList().get(row);
     StockEventType stState = stock.isTriggered();
     state.add(row, stState);
   }
 }
Exemple #2
0
 @Override
 public Object getValueAt(int row, int col) {
   switch (col) {
     case 0: // ticker
       return stocks.getStockList().get(row).getTicker();
     case 1: // price
       return stocks.getStockList().get(row).getCurrPrice();
     case 2: // open
       return stocks.getStockList().get(row).getOpenPrice();
     case 3: // high
       return stocks.getStockList().get(row).getTodayHigh();
     case 4: // low
       return stocks.getStockList().get(row).getTodayLow();
     default:
       return "ERR";
   }
 }
Exemple #3
0
 public boolean refresh() {
   this.fireTableRowsUpdated(0, stocks.getStockList().size() - 1);
   boolean flag = false;
   for (int row = 0; row < stocks.getStockList().size(); row++) {
     Stock stock = stocks.getStockList().get(row);
     StockEventType stState = stock.isTriggered();
     if (stState != state.get(row)) {
       state.set(row, stState);
       if (stState == StockEventType.BUY
           || stState == StockEventType.CONFLICT
           || stState == StockEventType.SELL) {
         flag = true;
       }
     }
   }
   return flag;
 }
Exemple #4
0
  public Stock removeStock(int i) {
    if (i == -1) return null;

    selector.deselect(i);
    Stock stock = stocks.getStockList().remove(i);
    state.remove(i);
    this.fireTableRowsDeleted(i, i);
    return stock;
  }
Exemple #5
0
 public Stock removeLastStock() {
   int i = stocks.getStockList().size() - 1;
   return removeStock(i);
 }
Exemple #6
0
 public void addLastStock(Stock stock) {
   stocks.add(stock);
   state.add(stock.isTriggered());
   this.fireTableRowsInserted(stocks.getStockList().size() - 1, stocks.getStockList().size() - 1);
   selector.select(stocks.getStockList().size() - 1);
 }
Exemple #7
0
 @Override
 public int getRowCount() {
   if (stocks == null) return 0;
   return stocks.getStockList().size();
 }
Exemple #8
0
 public Stock getStock(int index) {
   if (index == -1 || index > stocks.getStockList().size()) return null;
   return stocks.getStockList().get(index);
 }