public EventMediaPlayer(EEventMediaType media, ReadOnlyDoubleProperty parentWidth) { this.parentWidth = parentWidth; this.type = media; this.getStyleClass().add("root"); } @Override
Label title = new Label(control.getTitle()); title.getStyleClass().add("title"); title.textProperty().bind(control.titleProperty()); Image titleImg = createImage("ParchmentTitleScroll.png"); final double titleWidth = titleImg.getWidth(); Text desc = new Text(control.getDescription()); desc.getStyleClass().add("description"); desc.setTextAlignment(TextAlignment.CENTER); desc.textProperty().bind(control.descriptionProperty()); desc.setWrappingWidth(frame.getInnerDimension().getWidth()); String resourcePath = control.getType().getResource(); String sourcePath = getClass().getClassLoader().getResource(resourcePath).toExternalForm(); Media media = new Media(sourcePath); background.setWidth(newValue.getWidth()); background.setHeight(newValue.getHeight()); Dimension2D titleDim = textSize.calculate(control.getTitle(), openPatrician24); title.setLayoutX((newValue.getWidth() - titleDim.getWidth())/2 + frame.getInsetBackground().getX()); titleBackground.setLayoutX((newValue.getWidth() - titleWidth)/2 + frame.getInsetBackground().getX() + 20); background.setLayoutX(newValue.getX()); background.setLayoutY(newValue.getX()); Dimension2D titleDim = textSize.calculate(control.getTitle(), openPatrician24); Dimension2D descDimension = textSize.calculate(control.getDescription(), openPatrician18); double wrappingWidth = Math.min(descDimension.getWidth(), newValue.getWidth()); desc.setWrappingWidth(wrappingWidth);
private void displayEventVideoUnwrapped(DisplayEventVideo event) { closeEventView(); String title = messageSource.getMessage(event.getTitleKey(), event.getTitleParams(), locale.getCurrentLocal()); String description = messageSource.getMessage(event.getDescriptionKey(), event.getDescriptionParams(), locale.getCurrentLocal()); eventViewer = new EventMediaPlayer(event.getMediaType(), new SimpleDoubleProperty(controlWidth)); eventViewer.setTitle(title); eventViewer.setDescription(description); eventViewer.setLayoutX((0.35 * controlWidth) / 2); eventViewer.setLayoutY(30); getChildren().add(eventViewer); uiTimer.schedule(() -> Platform.runLater(this::closeEventView), event.getDurationInSeconds() + 5, TimeUnit.SECONDS); }