private DecoratedText initializeDecoratedText(final String template, Map<String, Object> parameters, DecoratedText text) { text.getStylesheets().add(DecoratedText.class.getResource(DecoratedText.class.getSimpleName() + ".css").toExternalForm()); text.getStyleClass().add("decoratedText"); text.setLayoutY(topInset); text.setLayoutX(leftInset); text.setWrappingWidth(wrappingWidth); String[] lines = template.split("\n"); for (int i = 0; i < lines.length; i++) { String curTemplate = lines[i]; if (i == lines.length -1 && template.endsWith("\n") || i < lines.length -1){ curTemplate += "\n"; } text = replaceParameters(text, curTemplate, parameters); } return text; }
private NoticeBoardMenuEntry createMenuEntry(ICityPlayerProxyJFX proxy, INavigableVessel vessel, String loadedText, boolean disabled, int wrappingWidth) { DecoratedText dt = textFactory.createDecoratedText(loadedText, new HashMap<>()); dt.setWrappingWidth(210); NoticeBoardMenuEntry entry = new NoticeBoardMenuEntry(null); entry.setLabel(dt); entry.setDisabled(disabled); entry.setSelected(vessel.equals(proxy.getActiveShip())); return entry; }
@PostConstruct private void initializeDialog() { setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernFugitiveDialog.title", new Object[]{}, locale.getCurrentLocal())); initializeButtons(); IFugitive fugitive = (IFugitive) currentPerson.get(); DecoratedText text = new DecoratedText(); text.setLayoutX(2 * Dialog.FRAME_BORDER); text.setLayoutY(100); text.setWrappingWidth(Dialog.WRAPPING_WIDTH); String loadedText = messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.TavernFugitiveDialog.dialog", new Object[0], locale.getCurrentLocal()); HashMap<String, Object> parameters = new HashMap<>(); parameters.put("destination", fugitive.getDestination().getName()); parameters.put("amount", fugitive.getPremium()); DecoratedText dt = decoratedTextFactory.createDecoratedText(loadedText, parameters); getContent().addAll(dt); }