public final Object getValueAt(final int row, final int col) { long id = shopTable.getOffers().get(row).itemId; Item item = ItemStore.itemForId(id); long stock = shopTable.getOffers().get(row).amountAvailable; long in_inventory = inventory.getSlotWithItemId(id).getNumberOfItems(); int category = shownCategories.get(col); switch (category) { case ID: return id; case SYMBOL: return item.getId(); case NAME: return item.getName(); case VALUE: return item.getPrice(); case ATTACK: return item.getAttack(); case ARMOR: return item.getArmor(); case STOCK: return stock; case IN_INVENTORY: return in_inventory; default: return null; } }
public final int getRowCount() { return shopTable.getOffers().size(); }
public ShopTableModel(final ShopTable shopTable) { this.shopTable = shopTable; this.inventory = shopTable.getInventory(); inventory.addInventoryChangeListener(this); this.shownCategories = new ArrayList<>(); }