public static void updateBackground(Background newBackground, Region nodeToUpdate, Paint fill) { if (newBackground != null && !newBackground.getFills().isEmpty()) { final BackgroundFill[] fills = new BackgroundFill[newBackground.getFills().size()]; for (int i = 0; i < newBackground.getFills().size(); i++) { BackgroundFill bf = newBackground.getFills().get(i); fills[i] = new BackgroundFill(fill, bf.getRadii(), bf.getInsets()); } nodeToUpdate.setBackground(new Background(fills)); } }
public void updateUnfocusColor() { Paint paint = control.getUnFocusColor(); line.setBackground(paint == null ? Background.EMPTY : new Background(new BackgroundFill(paint, CornerRadii.EMPTY, Insets.EMPTY))); }
public void updateFocusColor() { Paint paint = control.getFocusColor(); focusedLine.setBackground(paint == null ? Background.EMPTY : new Background(new BackgroundFill(paint, CornerRadii.EMPTY, Insets.EMPTY))); }
public JFXPopupSkin(JFXPopup control) { this.control = control; // set scale y to 0.01 instead of 0 to allow layout of the content, // otherwise it will cause exception in traverse engine, when focusing the 1st node scale = new Scale(1, 0.01, 0, 0); popupContent = control.getPopupContent(); container.getStyleClass().add("jfx-popup-container"); container.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY))); container.getChildren().add(popupContent); container.getTransforms().add(scale); container.setOpacity(0); root = JFXDepthManager.createMaterialNode(container, 4); animation = getAnimation(); }
private JFXButton createNextButton(TreeItem temp) { return new JFXButton(temp.getValue().toString()) { { setPadding(new Insets(getOffset(), 1.5 * getOffset(), getOffset(), 2 * getOffset())); setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); } @Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width - getOffset(), 0.0, width, height / 2, width - getOffset(), height, 0.0, height, getOffset(), height / 2}); setClip(polygon); } }; }
private void createWeekDaysCells() { // create week days names for (int i = 0; i < daysPerWeek; i++) { DateCell cell = new DateCell(); cell.getStyleClass().add("day-name-cell"); cell.setTextFill(DEFAULT_CELL_COLOR); cell.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); cell.setFont(Font.font(ROBOTO, FontWeight.BOLD, 12)); cell.setAlignment(Pos.BASELINE_CENTER); weekDaysCells.add(cell); } // create week days numbers for (int i = 0; i < 6; i++) { DateCell cell = new DateCell(); cell.getStyleClass().add("week-number-cell"); cell.setTextFill(DEFAULT_CELL_COLOR); cell.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); cell.setFont(Font.font(ROBOTO, FontWeight.BOLD, 12)); weekNumberCells.add(cell); } }
private JFXButton createLastButton(TreeItem temp, TreeItem parent) { return new JFXButton(temp.getValue().toString()) { private boolean noParent = parent == null; { setPadding(new Insets(getOffset(), getOffset(), getOffset(), (noParent? 1 : 2) * getOffset())); setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); } @Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width, 0.0, width, height, 0.0, height, noParent ? 0 : getOffset(), noParent ? 0 : height / 2}); setClip(polygon); } }; }
public JFXButton createFirstButton(TreeItem temp) { return new JFXButton(temp.getValue().toString()) { { setPadding(new Insets(getOffset(), 1.5 * getOffset(), getOffset(), getOffset())); setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); } @Override protected void layoutChildren() { super.layoutChildren(); double width = getWidth(); Polygon polygon = new Polygon(); final double height = getHeight(); polygon.getPoints().addAll(new Double[] { 0.0, 0.0, width - getOffset(), 0.0, width, height / 2, width - getOffset(), height, 0.0, height}); setClip(polygon); } }; }
private void initStyle(StackPane pane) { pane.setOpacity(1); pane.setPrefSize(30, 4); pane.setBackground(new Background(new BackgroundFill(Color.BLACK, new CornerRadii(5), Insets.EMPTY))); }
private void initialize() { this.setVisible(false); this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.transitionType.addListener((o, oldVal, newVal) -> { animation = getShowAnimation(transitionType.get()); }); contentHolder = new StackPane(); contentHolder.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(2), null))); JFXDepthManager.setDepth(contentHolder, 4); contentHolder.setPickOnBounds(false); // ensure stackpane is never resized beyond it's preferred size contentHolder.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); this.getChildren().add(contentHolder); this.getStyleClass().add("jfx-dialog-overlay-pane"); StackPane.setAlignment(contentHolder, Pos.CENTER); this.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.1), null, null))); // close the dialog if clicked on the overlay pane if (overlayClose.get()) { this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } // prevent propagating the events to overlay pane contentHolder.addEventHandler(MouseEvent.ANY, e -> e.consume()); }
private void init() { setClip(clip); clip.setBackground(new Background(new BackgroundFill(Color.BLACK, new CornerRadii(2), Insets.EMPTY))); backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(getBackground(), clip)); }
public void updateSelectionBackground() { CornerRadii radii = getSkinnable().getBackground() == null ? CornerRadii.EMPTY : getSkinnable().getBackground() .getFills() .get(0) .getRadii(); Insets insets = getSkinnable().getBackground() == null ? Insets.EMPTY : getSkinnable().getBackground() .getFills() .get(0) .getInsets(); selectionOverLay.setBackground(new Background(new BackgroundFill(getSkinnable().isSelected() ? ((JFXToggleNode) getSkinnable()) .getSelectedColor() : ((JFXToggleNode) getSkinnable()).getUnSelectedColor(), radii, insets))); }
public JFXTreeCell() { selectedPane.getStyleClass().add("selection-bar"); selectedPane.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY))); selectedPane.setPrefWidth(3); selectedPane.setMouseTransparent(true); selectedProperty().addListener((o, oldVal, newVal) -> selectedPane.setVisible(newVal ? true : false)); final InvalidationListener treeItemInvalidationListener = observable -> { TreeItem<T> oldTreeItem = treeItemRef == null ? null : treeItemRef.get(); if (oldTreeItem != null) { oldTreeItem.graphicProperty().removeListener(weakTreeItemGraphicListener); } TreeItem<T> newTreeItem = getTreeItem(); if (newTreeItem != null) { newTreeItem.graphicProperty().addListener(weakTreeItemGraphicListener); treeItemRef = new WeakReference<>(newTreeItem); } }; final WeakInvalidationListener weakTreeItemListener = new WeakInvalidationListener(treeItemInvalidationListener); treeItemProperty().addListener(weakTreeItemListener); if (getTreeItem() != null) { getTreeItem().graphicProperty().addListener(weakTreeItemGraphicListener); } }
/** * creates empty drawer node */ public JFXDrawer() { initialize(); contentHolder.setPickOnBounds(false); addEventHandler(JFXDrawerEvent.CLOSED, handler -> Platform.runLater(() -> getCachePolicy().restore(contentHolder))); overlayPane.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.1), CornerRadii.EMPTY, Insets.EMPTY))); overlayPane.getStyleClass().add("jfx-drawer-overlay-pane"); overlayPane.setOpacity(0); overlayPane.setMouseTransparent(true); sidePane.getStyleClass().add("jfx-drawer-side-pane"); sidePane.setBackground(new Background(new BackgroundFill(Color.rgb(255, 255, 255, 1), CornerRadii.EMPTY, Insets.EMPTY))); sidePane.setPickOnBounds(false); translateTimer.setCacheNodes(sidePane); // add listeners initListeners(); // init size value setDefaultDrawerSize(100); getChildren().setAll(contentHolder, overlayPane, sidePane); }
public void updateDisabled() { final boolean disabled = control.isDisable(); line.setBorder(!disabled ? Border.EMPTY : new Border(new BorderStroke(control.getUnFocusColor(), BorderStrokeStyle.DASHED, CornerRadii.EMPTY, new BorderWidths(1)))); line.setBackground(new Background( new BackgroundFill(disabled ? Color.TRANSPARENT : control.getUnFocusColor(), CornerRadii.EMPTY, Insets.EMPTY))); } }
/** * {@inheritDoc} */ @Override protected void interpolate(double frac) { if (start == null) { starting(); } Color newColor = start.interpolate(end, frac); if (Color.TRANSPARENT.equals(start)) { newColor = new Color(end.getRed(), end.getGreen(), end.getBlue(), newColor.getOpacity()); } region.get().setBackground(new Background(new BackgroundFill(newColor, radii, insets))); } }
private StackPane createMask() { StackPane mask = new StackPane(); mask.shapeProperty().bind(getSkinnable().shapeProperty()); mask.backgroundProperty().bind(Bindings.createObjectBinding(() -> { return new Background(new BackgroundFill(Color.WHITE, getSkinnable().getBackground() != null && getSkinnable().getBackground().getFills().size() > 0 ? getSkinnable().getBackground().getFills().get(0).getRadii() : CornerRadii.EMPTY, getSkinnable().getBackground() != null && getSkinnable().getBackground().getFills().size() > 0 ? getSkinnable().getBackground().getFills().get(0).getInsets() : Insets.EMPTY)); }, getSkinnable().backgroundProperty())); mask.resize(getWidth() - snappedRightInset() - snappedLeftInset(), getHeight() - snappedBottomInset() - snappedTopInset()); return mask; } };
public void initialize() { track = new StackPane(); track.getStyleClass().setAll("track"); bar = new StackPane(); bar.getStyleClass().setAll("bar"); secondaryBar = new StackPane(); secondaryBar.getStyleClass().setAll("secondary-bar"); clip = new Region(); clip.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))); bar.backgroundProperty().addListener(observable -> JFXNodeUtils.updateBackground(bar.getBackground(), clip)); getChildren().setAll(track, secondaryBar, bar); }
@Override protected void layoutChildren(final double x, final double y, final double w, final double h) { super.layoutChildren(x, y, w, h); final double height = getSkinnable().getHeight(); linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3); errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h); linesWrapper.updateLabelFloatLayout(); if (invalid) { invalid = false; // set the default background of text area viewport to white Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0); viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); // reapply css of scroll pane in case set by the user viewPort.applyCss(); errorContainer.invalid(w); // focus linesWrapper.invalid(); } }
@Override protected void layoutChildren(final double x, final double y, final double w, final double h) { super.layoutChildren(x, y, w, h); final double height = getSkinnable().getHeight(); linesWrapper.layoutLines(x, y, w, h, height, promptText == null ? 0 : promptText.getLayoutBounds().getHeight() + 3); errorContainer.layoutPane(x, height + linesWrapper.focusedLine.getHeight(), w, h); linesWrapper.updateLabelFloatLayout(); if (invalid) { invalid = false; // set the default background of text area viewport to white Region viewPort = (Region) scrollPane.getChildrenUnmodifiable().get(0); viewPort.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); // reapply css of scroll pane in case set by the user viewPort.applyCss(); errorContainer.invalid(w); // focus linesWrapper.invalid(); } }