private void addEmptyRow(Table model) { TableRow row; row = new TableRow(); row.add(new StaticTextTableCell("")); row.add(new StaticTextTableCell("")); row.add(new StaticTextTableCell("")); row.add(new StaticTextTableCell("")); model.add(row); } private static class LevelBinding extends StringBinding {
/** * Adding a table cell to the grid * @param grid grid pant to which to add. * @param rowNum row index * @param row table row * @param col column index * @param cell the node is pased on * @param hAlignment horizontal alignment * @param textStyleClass style class for the text */ public void addCellToGridPane(GridPane grid, int rowNum, TableRow row, int col, ITableCell cell, HPos hAlignment, String textStyleClass) { if (cell instanceof StaticTextTableCell) { Text text = new Text(((StaticTextTableCell)cell).getValue()); text.getStyleClass().add(textStyleClass); addCellToGridPane(rowNum, row, col, cell, text, grid, hAlignment); } else if (cell instanceof DynamicTextTableCell) { DynamicTextTableCell dynCell = (DynamicTextTableCell) cell; Text text = new Text(); text.textProperty().bind(dynCell.valueProperty()); text.getStyleClass().add(textStyleClass); addCellToGridPane(rowNum, row, col, cell, text, grid, hAlignment); } else if (cell instanceof ControlTableCell) { final Node control = ((ControlTableCell) cell).getControl(); addCellToGridPane(rowNum, row, col, cell, control, grid, hAlignment); } else { throw new RuntimeException("Not implemented"); } } /**
private Table createModel() { Table model = new Table(); TableHeader header = new TableHeader(2); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.model.people.impl.WeaponsDealerState.noticeboardTitle", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WeaponInventoryDialog.inStock", new Object[]{}, locale.getCurrentLocal()))); header.setAligenment(0, HPos.RIGHT); header.setAligenment(1, HPos.RIGHT); model.setHeader(header); model.setColumnWidth(100, 200); for (EWeapon weapon : EWeapon.values()) { TableRow row = new TableRow(); row.add(new StaticTextTableCell(translator.getLocalDisplayName(weapon))); row.add(new StaticTextTableCell(String.valueOf(weaponStorage.getWeapon(weapon)))); model.add(row); } return model; } @Override
@Override protected Table createMainTable() { Table model = new Table(); // Add dummy header which is not rendered TableHeader header = new TableHeader(2); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); model.setHeader(header); model.setColumnWidth(150, 200); TableRow row = new TableRow(); row.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.ShipyardRenameDialogV2.shipName", new Object[]{}, locale.getCurrentLocal()))); shipNameInput = new OpenPatricianDialogInput(""); shipNameInput.getStyleClass().add("defaultLabelFont"); shipNameInput.textProperty().bindBidirectional(shipName); row.add(new ControlTableCell(shipNameInput)); model.add(row); return model; }
@Override protected Table createTopTable() { Table model = new Table(); // Add dummy header which is not rendered TableHeader header = new TableHeader(4); model.setHeader(header); model.setColumnWidth(70, 70, 70, 70); TableRow row = new TableRow(); BarrelAmount capacityAmount = new BarrelAmount(); capacityAmount.setAmount(currentShip.get().getLoadableSpace()); row.add(new ControlTableCell(capacityAmount)); row.add(new StaticTextTableCell(String.valueOf(100 - currentShip.get().getDamage()))); row.add(new StaticTextTableCell(String.valueOf(currentShip.get().getNumberOfSailors()))); row.add(new StaticTextTableCell("1")); model.add(row); return model; }
@Override protected Table createTopTable() { int capacity = shipFactory.calculateInitialCapacity(getCurrentShipType(), getCity().getCoordinates().getX()); List<IWeaponSlot> shipWeapons = weaponsLocationFactory.getShipWeaponsLocation(getCurrentShipType(), EShipUpgrade.NONE); Table model = new Table(); // Add dummy header which is not rendered TableHeader header = new TableHeader(5); model.setHeader(header); model.setColumnWidth(70, 70, 70, 70, 70); TableRow row = new TableRow(); BarrelAmount capacityAmount = new BarrelAmount(); capacityAmount.setAmount(capacity); row.add(new ControlTableCell(capacityAmount)); WeaponSlotCount slotCount = shipService.getWeaponSlotCount(shipWeapons); row.add(new StaticTextTableCell(String.valueOf(slotCount.getNbSmallSlots()))); row.add(new StaticTextTableCell(String.valueOf(slotCount.getNbLargeSlots()))); row.add(new StaticTextTableCell(String.valueOf(shipFactory.getShipSpeed(getCurrentShipType())))); row.add(new StaticTextTableCell(String.valueOf(shipFactory.getMinimalSailors(getCurrentShipType())))); model.add(row); return model; }
@Override protected Table createTopTable() { int capacity = shipFactory.calculateInitialCapacity(getCurrentShipType(), getCity().getCoordinates().getX()); List<IWeaponSlot> shipWeapons = weaponsLocationFactory.getShipWeaponsLocation(getCurrentShipType(), EShipUpgrade.NONE); Table model = new Table(); // Add dummy header which is not rendered TableHeader header = new TableHeader(5); model.setHeader(header); model.setColumnWidth(70, 70, 70, 70, 70); TableRow row = new TableRow(); BarrelAmount capacityAmount = new BarrelAmount(); capacityAmount.setAmount(capacity); row.add(new ControlTableCell(capacityAmount)); WeaponSlotCount slotCount = shipService.getWeaponSlotCount(shipWeapons); row.add(new StaticTextTableCell(String.valueOf(slotCount.getNbSmallSlots()))); row.add(new StaticTextTableCell(String.valueOf(slotCount.getNbLargeSlots()))); row.add(new StaticTextTableCell(String.valueOf(shipFactory.getShipSpeed(getCurrentShipType())))); row.add(new StaticTextTableCell(String.valueOf(shipFactory.getMinimalSailors(getCurrentShipType())))); model.add(row); return model; }
@Override protected Table createTopTable() { Table model = new Table(); // Add dummy header which is not rendered TableHeader header = new TableHeader(3); model.setHeader(header); model.setColumnWidth(70, 70, 70); TableRow row = new TableRow(); BarrelAmount capacityAmount = new BarrelAmount(); capacityAmount.setAmount(currentShip.get().getLoadableSpace()); row.add(new ControlTableCell(capacityAmount)); row.add(new StaticTextTableCell(String.valueOf(100 - currentShip.get().getDamage()))); row.add(new StaticTextTableCell(String.valueOf(currentShip.get().getNumberOfSailors()))); model.add(row); return model; } @Override
header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.armory.HandWeaponDialog.header.amrory", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.armory.HandWeaponDialog.header.buy", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.armory.HandWeaponDialog.header.prio", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.armory.HandWeaponDialog.header.tradingOffice", new Object[]{}, locale.getCurrentLocal()))); header.setAligenment(0, HPos.RIGHT); header.setAligenment(1, HPos.RIGHT);
header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.armory.ShipWeaponDialog.header.amrory", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.armory.ShipWeaponDialog.header.buy", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.armory.ShipWeaponDialog.header.sell", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.armory.ShipWeaponDialog.header.tradingOffice", new Object[]{}, locale.getCurrentLocal()))); header.setAligenment(0, HPos.RIGHT); header.setAligenment(1, HPos.RIGHT);
Table model = new Table(); TableHeader header = new TableHeader(5); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); header.setAligenment(0, HPos.RIGHT); header.setAligenment(1, HPos.LEFT); model.setColumnWidth(100, 50, 100, 50, 150); TableRow row = new TableRow(); row.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TradeOfficeBalanceDialog.rentalIncome", new Object[]{}, locale.getCurrentLocal()))); row.add(new StaticTextTableCell("")); StringBinding rentalIncomeLastWeek = new DateBoundStringProperty() { @Override coinPrice.amountProperty().bind(rentalIncomeLastWeek); row.add(new ControlTableCell(coinPrice)); row.add(new StaticTextTableCell("")); StringBinding rentalIncomeForecast = new DateBoundStringProperty() { @Override row.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TradeOfficeBalanceDialog.wages", new Object[]{}, locale.getCurrentLocal()))); row.add(new StaticTextTableCell("")); StringBinding wagesIncomeLastWeek = new DateBoundStringProperty() { @Override coinPrice.amountProperty().bind(wagesIncomeLastWeek);
@Override protected Table createMainTable() { Table model = new Table(); // Add dummy header which is not rendered TableHeader header = new TableHeader(1); model.setHeader(header); model.setColumnWidth(200); TableRow row = new TableRow(); row.add(new StaticTextTableCell(currentShip.get().getName())); model.add(row); return model; }
header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.BaseTradeDialog.ware", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.CityProductionConsumptionDialog.stock", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.BaseTradeDialog.city", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.CityProductionConsumptionDialog.shops", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.CityProductionConsumptionDialog.pop", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.CityProductionConsumptionDialog.shops", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.CityProductionConsumptionDialog.tot", new Object[]{}, locale.getCurrentLocal()))); model.setHeader(header); model.setAligenment(0, HPos.RIGHT); TableRow row = new TableRow(); row.add(new StaticTextTableCell(translator.getLocalDisplayName(ware)));
header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); model.setHeader(header); model.setAligenment(0, HPos.LEFT); row.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.StorageOverviewDialog.requiredCapacity", new Object[]{}, locale.getCurrentLocal()))); row.add(new StaticTextTableCell("")); Text amount = new Text(); amount.getStyleClass().add("dialogText"); row.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.StorageOverviewDialog.availableCap", new Object[]{}, locale.getCurrentLocal()))); row.add(new StaticTextTableCell("")); Text capacityTxt = new Text(); capacityTxt.getStyleClass().add("dialogText"); row.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.StorageOverviewDialog.additionalCap", new Object[]{}, locale.getCurrentLocal()))); row.add(new StaticTextTableCell("")); IntegerBinding additionalAmount = new IntegerBinding() { row.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.StorageOverviewDialog.otherGoods", new Object[]{}, locale.getCurrentLocal()))); row.add(new StaticTextTableCell("")); Text otherTxt = new Text(); otherTxt.getStyleClass().add("dialogText"); row.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.StorageOverviewDialog.costs", new Object[]{}, locale.getCurrentLocal()))); row.add(new StaticTextTableCell("")); Text storageCosts = new Text();
Table model = new Table(); TableHeader header = new TableHeader(4); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.BaseTradeDialog.ware", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WareInStockDialog.stockInCity", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WareInStockDialog.fromCity", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WareInStockDialog.toCity", new Object[]{}, locale.getCurrentLocal()))); header.setAligenment(0, HPos.RIGHT); header.setAligenment(1, HPos.CENTER); for (EWare ware : EWare.values()) { TableRow row = new TableRow(); row.add(new StaticTextTableCell(translator.getLocalDisplayName(ware)));
header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WeaponTransferDialog.header.weapon", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WeaponTransferDialog.header.ship", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WeaponTransferDialog.header.transfer", new Object[]{}, locale.getCurrentLocal())), ECellConstraint.COLSPAN2); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.WeaponTransferDialog.header.storage", new Object[]{}, locale.getCurrentLocal()))); header.setAligenment(0, HPos.RIGHT); header.setAligenment(1, HPos.RIGHT); for (EWeapon weapon : weapons) { TableRow row = new TableRow(); row.add(new StaticTextTableCell(translator.getLocalDisplayName(weapon))); DynamicTextTableCell shipAmount = new DynamicTextTableCell(); IntegerBinding shipAmountBinding = shipAmount(weapon, ship);
String s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.BaseTradeDialog.ware", new Object[]{}, locale.getCurrentLocal()); header.add(new StaticTextTableCell(s)); s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.CityStorageTradeDialog.storage", new Object[]{}, locale.getCurrentLocal()); header.add(new StaticTextTableCell(s)); header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); s = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.church.ChurchFeedingDialog.donation", new Object[]{}, locale.getCurrentLocal()); header.add(new StaticTextTableCell(s)); header.setAligenment(0, HPos.LEFT); header.setAligenment(1, HPos.CENTER); for (final EWare ware : MATERIALS) { final TableRow row = new TableRow(); row.add(new StaticTextTableCell(translator.getLocalDisplayName(ware)));
header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernWeaponsDealerDialog.weaponType", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernWeaponsDealerDialog.dealer", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.BaseTradeDialog.buy", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.BaseTradeDialog.sell", new Object[]{}, locale.getCurrentLocal()))); Text storageHeader = new Text(); storageHeader.getStyleClass().add("dialogText"); row.add(new StaticTextTableCell(translator.getLocalDisplayName(weapon))); Text dealerAmount = new Text(); dealerAmount.getStyleClass().add("dialogText");
header.add(new StaticTextTableCell("")); header.add(new StaticTextTableCell("")); tableModel.setHeader(header); tableModel.setColumnWidth(300, 100); row.add(new StaticTextTableCell(template)); CoinPriceAlwaysVisible control = new CoinPriceAlwaysVisible(); control.amountProperty().bind(treasury.paidTaxesProperty().asString()); row.add(new StaticTextTableCell(template)); control = new CoinPriceAlwaysVisible(); control.amountProperty().bind(treasury.paidSpecialTaxesProperty().asString()); row.add(new StaticTextTableCell(template)); control = new CoinPriceAlwaysVisible(); control.amountProperty().bind(treasury.donationsProperty().asString()); row.add(new StaticTextTableCell(template)); control = new CoinPriceAlwaysVisible(); control.amountProperty().bind(treasury.cityGuardCostsProperty().asString()); row.add(new StaticTextTableCell(template)); control = new CoinPriceAlwaysVisible(); control.amountProperty().bind(treasury.buildingCostsProperty().asString()); row.add(new StaticTextTableCell(template)); control = new CoinPriceAlwaysVisible(); control.amountProperty().bind(treasury.outriggerCostsProperty().asString());
Table model = new Table(); TableHeader header = new TableHeader(5); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.ShipyardConstructionDialogV2.materials", new Object[]{}, locale.getCurrentLocal())), ECellConstraint.COLSPAN2); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.ShipyardConstructionDialogV2.stored", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.ShipyardConstructionDialogV2.buy", new Object[]{}, locale.getCurrentLocal()))); header.add(new StaticTextTableCell(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.ShipyardConstructionDialogV2.costs", new Object[]{}, locale.getCurrentLocal()))); header.setAligenment(0, HPos.CENTER); header.setAligenment(2, HPos.CENTER); row.add(new StaticTextTableCell(translator.getLocalDisplayName(ware)));