@Override public PaginationV2 build() { return new PaginationV2(backButtonLabel, nextButtonLabel, backButtonNode, nextButtonNode, firstLastPageAction, text, contentMaxWidth, contentMaxHeight, paddingLocal, navigationLabelFont, headerFont, paragraphFont, centeredFont); } }
@Override public void handle(MouseEvent event) { if (currentPage < pages.size()-1) { currentPage++; // display next page updateDisplay(); backButtonVisibility.set(true); if (currentPage == pages.size()-1 && control.getFirstLastPageAction() == null) { nextButtonVisibility.set(false); } } else if (currentPage == pages.size()-1) { control.getFirstLastPageAction().handle(event); // delegate } } }
public PaginationSkinV2(final PaginationV2 control) { super(control); this.control = control; control.getStyleClass().add("paginationBG"); backButtonVisibility = new SimpleBooleanProperty(this, "backButtonVisibility", control.getFirstLastPageAction() != null); nextButtonVisibility = new SimpleBooleanProperty(this, "nextButtonVisibility", true); backButtonEventHandler = new BackButtonEventHandler(); backLbl = new Label(); backLbl.setId(getClass().getName() + "backButton"); backLbl.fontProperty().bind(control.navigationLabelFontProperty()); backLbl.textProperty().bind(control.backButtonLabelProperty()); backLbl.visibleProperty().bind(backButtonVisibility); backLbl.setPadding(defaultInsets); nextLbl = new Label(); nextLbl.setId(getClass().getName() + "nextButton"); nextLbl.fontProperty().bind(control.navigationLabelFontProperty()); nextLbl.textProperty().bind(control.nextButtonLabelProperty()); nextLbl.visibleProperty().bind(nextButtonVisibility); nextLbl.setPadding(defaultInsets); contentContainer = new VBox(); contentContainer.getStyleClass().add("containerVBox"); contentContainer.setMaxWidth(control.getContentMaxWidth()); contentContainer.setPadding(defaultInsets); contentHeight.bind(control.contentMaxHeightProperty()); contentWidth = new SimpleDoubleProperty(this, "contentWidth", 0.0); DoubleBinding contentWidthBinding = control.contentMaxWidthProperty() .subtract(control.paddingLocalProperty().getValue().getLeft())
/** * Refresh the content to be displayed on the current page. */ private void updateDisplay() { clearContents(); Page page = pages.get(currentPage); for (Line line : page.getLines()) { final Label l = new Label(line.getLine()); l.getStyleClass().add(line.getStyleClass()); if (line.getStyleClass().equals(PageSplitter.CENTERED_STYLE)){ l.setFont(control.getCenteredFont()); BorderPane centered = new BorderPane(); centered.setCenter(l); contentContainer.getChildren().add(centered); } else { switch (line.getStyleClass()) { case PageSplitter.PARAGRAPH_STYLE: l.setFont(control.getParagraphFont()); break; case PageSplitter.HEADING_STYLE: l.setFont(control.getHeaderFont()); break; default: throw new IllegalStateException("Unknown style for font setting"); } contentContainer.getChildren().add(l); } } } /**
/** * Split up the text into lines and pages, that can be displayed. * @param text component that is to be split up. */ private void splitTextToPages(Text text) { final double width = getContentWidth(); final double heigh = contentHeight.doubleValue(); Font font = control.getNavigationLabelFont(); PageSplitter splitter = new PageSplitter(heigh, width, contentContainer.getSpacing(), calculateContentInitialHeigth(), font); splitter.setWordSplitter(new NonAlphaNumWordSplitter()); pages.addAll(splitter.splitIntoPages(text)); } private double getContentWidth() {
@Override public void handle(MouseEvent event) { if (currentPage > 0) { currentPage--; // display last page updateDisplay(); nextButtonVisibility.set(true); if (currentPage == 0 && control.getFirstLastPageAction() == null) { backButtonVisibility.set(false); } } else if (currentPage == 0) { control.getFirstLastPageAction().handle(event); // delegate } } }