javafx.beans.binding.Bindings Java Examples

The following examples show how to use javafx.beans.binding.Bindings. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EditionPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
public void initialize() {
    edition.setShowTransitionFactory(BounceInRightTransition::new);
    
    edition.showingProperty().addListener((obs, oldValue, newValue) -> {
        if (newValue) {
            AppBar appBar = getApp().getAppBar();
            appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> 
                    getApp().getDrawer().open()));
            appBar.setTitleText("Edition");
        }
    });
    
    submit.disableProperty().bind(Bindings.createBooleanBinding(() -> {
            return authorText.textProperty().isEmpty()
                    .or(commentsText.textProperty().isEmpty()).get();
        }, authorText.textProperty(), commentsText.textProperty()));
}
 
Example #2
Source File: RectangularImageViewSkin.java    From WorkbenchFX with Apache License 2.0 6 votes vote down vote up
RectangularImageViewSkin(RectangularImageView control) {
  super(control);

  clip = new Rectangle(getWidthToFit(), getHeightToFit());

  imageView = new ImageView();
  imageView.setSmooth(true);
  imageView.setClip(clip);
  imageView.imageProperty().bind(
      Bindings.createObjectBinding(() -> getImage(getSkinnable().getImageURL()),
          getSkinnable().imageURLProperty()));

  getSkinnable().imageSizeProperty().addListener((observable, oldValue, newValue) -> {
    clip.setWidth(getWidthToFit());
    clip.setHeight(getHeightToFit());
    getSkinnable().requestLayout();
  });

  getChildren().add(imageView);
}
 
Example #3
Source File: FilesArrangeController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeNext() {
    try {
        initDirTab();
        initConditionTab();

        startButton.disableProperty().bind(
                Bindings.isEmpty(sourcePathInput.textProperty())
                        .or(Bindings.isEmpty(targetPathInput.textProperty()))
                        .or(sourcePathInput.styleProperty().isEqualTo(badStyle))
                        .or(targetPathInput.styleProperty().isEqualTo(badStyle))
        );

        operationBarController.openTargetButton.disableProperty().bind(
                startButton.disableProperty()
        );

    } catch (Exception e) {
        logger.debug(e.toString());
    }

}
 
Example #4
Source File: TableSelectListener.java    From Animu-Downloaderu with MIT License 6 votes vote down vote up
@Override
public TableRow<DownloadInfo> call(TableView<DownloadInfo> view) {
	final TableRow<DownloadInfo> row = new TableRow<>();
	DownloadInfo info = view.getSelectionModel().getSelectedItem();
	initListeners(view, info);
	row.contextMenuProperty().bind(
			Bindings.when(Bindings.isNotNull(row.itemProperty())).then(rowMenu).otherwise((ContextMenu) null));

	row.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
		final int index = row.getIndex();
		if (!event.isPrimaryButtonDown())
			return; // no action if it is not primary button
		if (index >= view.getItems().size() || view.getSelectionModel().isSelected(index)) {
			view.getSelectionModel().clearSelection();
			event.consume();
		}
	});
	return row;
}
 
Example #5
Source File: ImageManufactureBatchTextController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeNext() {
    try {

        startButton.disableProperty().unbind();
        startButton.disableProperty().bind(Bindings.isEmpty(targetPathInput.textProperty())
                .or(targetPathInput.styleProperty().isEqualTo(badStyle))
                .or(Bindings.isEmpty(tableView.getItems()))
                .or(Bindings.isEmpty(waterInput.textProperty()))
                .or(waterXInput.styleProperty().isEqualTo(badStyle))
                .or(waterYInput.styleProperty().isEqualTo(badStyle))
                .or(marginInput.styleProperty().isEqualTo(badStyle))
        );

    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example #6
Source File: FilterableTreeItem.java    From Recaf with MIT License 6 votes vote down vote up
/**
 * @param value
 * 		Item value
 */
public FilterableTreeItem(T value) {
	super(value);
	// Support filtering by using a filtered list backing.
	// - Apply predicate to items
	FilteredList<TreeItem<T>> filteredChildren = new FilteredList<>(sourceChildren);
	filteredChildren.predicateProperty().bind(Bindings.createObjectBinding(() -> child -> {
		if(child instanceof FilterableTreeItem)
			((FilterableTreeItem<T>) child).predicateProperty().set(predicate.get());
		if(predicate.get() == null || !child.getChildren().isEmpty())
			return true;
		return predicate.get().test(child);
	}, predicate));
	// Reflection hackery
	setUnderlyingChildren(filteredChildren);
}
 
Example #7
Source File: MeshExporterDialog.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public MeshExporterDialog(final MeshInfo<T> meshInfo)
{
	super();
	this.meshInfo = meshInfo;
	this.dirPath = new TextField();
	this.setTitle("Export mesh");
	this.isError = (Bindings.createBooleanBinding(() -> dirPath.getText().isEmpty(), dirPath.textProperty()));
	final MeshSettings settings = meshInfo.getMeshSettings();
	this.scale = new TextField(Integer.toString(settings.getFinestScaleLevel()));
	UIUtils.setNumericTextField(scale, settings.getNumScaleLevels() - 1);

	setResultConverter(button -> {
		if (button.getButtonData().isCancelButton()) { return null; }
		return new MeshExportResult(
				meshExporter,
				filePath,
				Integer.parseInt(scale.getText())
		);
	});

	createDialog();
}
 
Example #8
Source File: UserInterfacePanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create the {@link ComboBox} containing the known themes
 *
 * @return A {@link ComboBox} containing the known themes
 */
private ComboBox<Theme> createThemeSelection() {
    final ComboBox<Theme> themeSelection = new ComboBox<>();

    Bindings.bindContent(themeSelection.getItems(), getControl().getThemes());

    themeSelection.valueProperty().bindBidirectional(getControl().selectedThemeProperty());
    themeSelection.setConverter(new StringConverter<>() {
        @Override
        public String toString(Theme theme) {
            return theme.getName();
        }

        @Override
        public Theme fromString(String themeName) {
            final Optional<Theme> foundTheme = getControl().getThemes().stream()
                    .filter(theme -> themeName.equals(theme.getName()))
                    .findFirst();

            return foundTheme.orElseThrow(
                    () -> new IllegalArgumentException("Couldn't find theme with name \"" + themeName + "\""));
        }
    });

    return themeSelection;
}
 
Example #9
Source File: SimpleButton.java    From cute-proxy with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void init() {
    Bindings.bindBidirectional(tooltipText, tooltipProperty(), new StringConverter<Tooltip>() {
        @Override
        public String toString(Tooltip tooltip) {
            if (tooltip == null) {
                return null;
            }
            return tooltip.getText();
        }

        @Override
        public Tooltip fromString(String string) {
            if (string == null) {
                return null;
            }
            return new Tooltip(string);
        }
    });
    iconPath.addListener((observable, oldValue, newValue) ->
            graphicProperty().set(new ImageView(new Image(getClass().getResourceAsStream(newValue)))));
}
 
Example #10
Source File: ImageManufactureBatchSizeController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeNext() {
    try {

        startButton.disableProperty().unbind();
        startButton.disableProperty().bind(Bindings.isEmpty(targetPathInput.textProperty())
                .or(targetPathInput.styleProperty().isEqualTo(badStyle))
                .or(Bindings.isEmpty(tableView.getItems()))
                .or(customWidthInput.styleProperty().isEqualTo(badStyle))
                .or(customHeightInput.styleProperty().isEqualTo(badStyle))
                .or(keepWidthInput.styleProperty().isEqualTo(badStyle))
                .or(keepHeightInput.styleProperty().isEqualTo(badStyle))
                .or(scaleBox.getEditor().styleProperty().isEqualTo(badStyle)));

    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example #11
Source File: RunnerResult.java    From curly with Apache License 2.0 6 votes vote down vote up
public RunnerResult() {
    durationBinding = Bindings.createLongBinding(() -> {
        if (startTime.get() == -1) {
            return 0L;
        } else if (endTime.get() == -1) {
            return System.currentTimeMillis() - startTime.get();
        } else {
            return endTime.get() - startTime.get();
        }
    }, startTime, endTime);

    started.addListener((prop, oldVal, newVal) -> {
        if (newVal && startTime.get() < 0) {
            startTime.set(System.currentTimeMillis());
        }
        invalidateBindings();
    });
    completed().addListener(((prop, oldVal, newVal) -> {
        if (newVal && endTime.get() < 0) {
            endTime.set(System.currentTimeMillis());
        }
        invalidateBindings();
    }));
}
 
Example #12
Source File: DemoView.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
private void setupBindings() {
  welcomeLbl.textProperty().bind(rootPane.welcomeText);
  brightnessLbl.textProperty().bind(rootPane.brightness.asString().concat("%"));
  nightModeLbl.textProperty().bind(rootPane.nightMode.asString());
  scalingLbl.textProperty().bind(rootPane.scaling.asString());
  screenNameLbl.textProperty().bind(rootPane.screenName);
  resolutionLbl.textProperty().bind(rootPane.resolutionSelection);
  orientationLbl.textProperty().bind(rootPane.orientationSelection);
  favoritesLbl.textProperty().bind(Bindings.createStringBinding(
      () -> rootPane.favoritesSelection.stream().collect(Collectors.joining(", ")),
      rootPane.favoritesSelection
  ));
  fontSizeLbl.textProperty().bind(rootPane.fontSize.asString());
  lineSpacingLbl.textProperty().bind(rootPane.lineSpacing.asString());
  favoriteNumberLbl.textProperty().bind(rootPane.customControlProperty.asString());
}
 
Example #13
Source File: ViewDot.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates the view.
 * @param sh The model.
 */
ViewDot(final Dot sh, final PathElementProducer pathProducer) {
	super(sh);
	this.pathProducer = pathProducer;
	path = new Path();
	dot = new Ellipse();
	getChildren().addAll(dot, path);

	model.styleProperty().addListener(updateDot);
	model.getPosition().xProperty().addListener(updateDot);
	model.getPosition().yProperty().addListener(updateDot);
	model.diametreProperty().addListener(updateDot);
	model.fillingColProperty().addListener(updateDot);
	model.lineColourProperty().addListener(updateStrokeFill);
	rotateProperty().bind(Bindings.createDoubleBinding(() -> Math.toDegrees(model.getRotationAngle()), model.rotationAngleProperty()));
	updateDot();
}
 
Example #14
Source File: NodeLink.java    From java_fx_node_link_demo with The Unlicense 6 votes vote down vote up
public void bindEnds (DraggableNode source, DraggableNode target) {
	node_link.startXProperty().bind(
			Bindings.add(source.layoutXProperty(), (source.getWidth() / 2.0)));
	
	node_link.startYProperty().bind(
			Bindings.add(source.layoutYProperty(), (source.getWidth() / 2.0)));
	
	node_link.endXProperty().bind(
			Bindings.add(target.layoutXProperty(), (target.getWidth() / 2.0)));
	
	node_link.endYProperty().bind(
			Bindings.add(target.layoutYProperty(), (target.getWidth() / 2.0)));
	
	source.registerLink (getId());
	target.registerLink (getId());
}
 
Example #15
Source File: ImageManufactureBatchMarginsController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeNext() {
    try {

        startButton.disableProperty().unbind();
        startButton.disableProperty().bind(Bindings.isEmpty(targetPathInput.textProperty())
                .or(targetPathInput.styleProperty().isEqualTo(badStyle))
                .or(Bindings.isEmpty(tableView.getItems()))
                .or(marginWidthBox.getEditor().styleProperty().isEqualTo(badStyle))
                .or(marginsTopCheck.styleProperty().isEqualTo(badStyle))
        );

    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example #16
Source File: PdfCompressImagesBatchController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeNext() {
    try {
        super.initializeNext();

        startButton.disableProperty().unbind();
        startButton.disableProperty().bind(
                Bindings.isEmpty(tableView.getItems())
                        .or(Bindings.isEmpty(targetPathInput.textProperty()))
                        .or(targetPathInput.styleProperty().isEqualTo(badStyle))
                        .or(jpegBox.styleProperty().isEqualTo(badStyle))
                        .or(thresholdInput.styleProperty().isEqualTo(badStyle))
                        .or(Bindings.isEmpty(tableView.getItems()))
        );
    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example #17
Source File: ContainerSidebarSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a {@link ContainersSidebarToggleGroup} object containing all installed containers
 */
private ContainersSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<ContainerCategoryDTO> filteredContainerCategories = getControl().getItems()
            .filtered(getControl().getFilter()::filter);

    filteredContainerCategories.predicateProperty().bind(
            Bindings.createObjectBinding(() -> getControl().getFilter()::filter,
                    getControl().searchTermProperty(),
                    getControl().selectedContainerCategoryProperty()));

    final ContainersSidebarToggleGroup sidebarToggleGroup = new ContainersSidebarToggleGroup(tr("Containers"),
            filteredContainerCategories);

    getControl().selectedContainerCategoryProperty().bind(sidebarToggleGroup.selectedElementProperty());

    return sidebarToggleGroup;
}
 
Example #18
Source File: ViewTriangle.java    From latexdraw with GNU General Public License v3.0 6 votes vote down vote up
private final void setupPath(final Path path) {
	final MoveTo moveTo = pathProducer.createMoveTo(0d, 0d);

	moveTo.xProperty().bind(Bindings.createDoubleBinding(() -> model.getPtAt(0).getX() + model.getWidth() / 2d,
		model.getPtAt(0).xProperty(), model.getPtAt(1).xProperty()));
	moveTo.yProperty().bind(model.getPtAt(0).yProperty());
	path.getElements().add(moveTo);

	LineTo lineTo = pathProducer.createLineTo(0d, 0d);
	lineTo.xProperty().bind(model.getPtAt(2).xProperty());
	lineTo.yProperty().bind(model.getPtAt(2).yProperty());
	path.getElements().add(lineTo);

	lineTo = pathProducer.createLineTo(0d, 0d);
	lineTo.xProperty().bind(model.getPtAt(3).xProperty());
	lineTo.yProperty().bind(model.getPtAt(3).yProperty());
	path.getElements().add(lineTo);

	path.getElements().add(pathProducer.createClosePath());
}
 
Example #19
Source File: ImageManufactureBatchCropController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeNext() {
    try {

        startButton.disableProperty().bind(Bindings.isEmpty(targetPathInput.textProperty())
                .or(targetPathInput.styleProperty().isEqualTo(badStyle))
                .or(Bindings.isEmpty(tableView.getItems()))
                .or(leftXInput.styleProperty().isEqualTo(badStyle))
                .or(leftYInput.styleProperty().isEqualTo(badStyle))
                .or(rightXInput.styleProperty().isEqualTo(badStyle))
                .or(rightYInput.styleProperty().isEqualTo(badStyle))
                .or(centerWidthInput.styleProperty().isEqualTo(badStyle))
                .or(centerHeightInput.styleProperty().isEqualTo(badStyle))
        );

    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example #20
Source File: BatchRunnerResult.java    From curly with Apache License 2.0 6 votes vote down vote up
public BatchRunnerResult() {
    reportRow().add(new ReadOnlyStringWrapper("Batch run"));
    
    StringBinding successOrNot = Bindings.when(completelySuccessful())
            .then(ApplicationState.getMessage(COMPLETED_SUCCESSFUL))
            .otherwise(ApplicationState.getMessage(COMPLETED_UNSUCCESSFUL));
    StringBinding successMessageBinding = Bindings.when(completed())
            .then(successOrNot).otherwise(ApplicationState.getMessage(INCOMPLETE));
    reportRow().add(successMessageBinding);

    reportRow().add(percentCompleteString().concat(" complete"));
    reportRow().add(percentSuccessString().concat(" success"));
    reportRow().add(getDuration());
    allBindings.add(successOrNot);
    allBindings.add(successMessageBinding);
}
 
Example #21
Source File: AutoCompleteItem.java    From BlockMap with MIT License 6 votes vote down vote up
public AutoCompleteItem() {
	name = new Label();
	name.setAlignment(Pos.CENTER_LEFT);
	name.setStyle("-fx-font-weight: bold;");

	path = new Label();
	path.setMaxWidth(Double.POSITIVE_INFINITY);
	HBox.setHgrow(path, Priority.ALWAYS);
	HBox.setMargin(path, new Insets(0, 8, 0, 0));
	path.setAlignment(Pos.CENTER_RIGHT);
	path.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);

	graphic = new ImageView();
	graphic.setPreserveRatio(true);
	graphic.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> name.getFont().getSize() * 1.2, name.fontProperty()));

	setText(null);
	setGraphic(new HBox(2, graphic, name, path));
	setPrefWidth(0);
}
 
Example #22
Source File: AutoCompletePopupSkin2.java    From BlockMap with MIT License 6 votes vote down vote up
/**
 * @param cellFactory
 *            Set a custom cell factory for the suggestions.
 */
public AutoCompletePopupSkin2(AutoCompletePopup<T> control, Callback<ListView<T>, ListCell<T>> cellFactory) {
	this.control = control;
	suggestionList = new ListView<>(control.getSuggestions());

	suggestionList.getStyleClass().add(AutoCompletePopup.DEFAULT_STYLE_CLASS);

	suggestionList.getStylesheets().add(AutoCompletionBinding.class
			.getResource("autocompletion.css").toExternalForm()); //$NON-NLS-1$
	/**
	 * Here we bind the prefHeightProperty to the minimum height between the max visible rows and the current items list. We also add an
	 * arbitrary 5 number because when we have only one item we have the vertical scrollBar showing for no reason.
	 */
	suggestionList.prefHeightProperty().bind(
			Bindings.min(control.visibleRowCountProperty(), Bindings.size(suggestionList.getItems()))
					.multiply(LIST_CELL_HEIGHT).add(18));
	suggestionList.setCellFactory(cellFactory);

	// Allowing the user to control ListView width.
	suggestionList.prefWidthProperty().bind(control.prefWidthProperty());
	suggestionList.maxWidthProperty().bind(control.maxWidthProperty());
	suggestionList.minWidthProperty().bind(control.minWidthProperty());
	registerEventListener();
}
 
Example #23
Source File: SimpleTextControl.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setupBindings() {
  super.setupBindings();

  editableArea.visibleProperty().bind(Bindings.and(field.editableProperty(),
      field.multilineProperty()));
  editableField.visibleProperty().bind(Bindings.and(field.editableProperty(),
      field.multilineProperty().not()));
  readOnlyLabel.visibleProperty().bind(field.editableProperty().not());

  editableField.textProperty().bindBidirectional(field.userInputProperty());
  editableArea.textProperty().bindBidirectional(field.userInputProperty());
  readOnlyLabel.textProperty().bind(field.userInputProperty());
  editableField.promptTextProperty().bind(field.placeholderProperty());
  editableArea.promptTextProperty().bind(field.placeholderProperty());

  editableArea.managedProperty().bind(editableArea.visibleProperty());
  editableField.managedProperty().bind(editableField.visibleProperty());
}
 
Example #24
Source File: EngineSidebarSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates the {@link EnginesSidebarToggleGroup} which contains all known engine categories
 */
private EnginesSidebarToggleGroup createSidebarToggleGroup() {
    final FilteredList<EngineCategoryDTO> filteredEngineCategories = getControl().getItems()
            .filtered(getControl().getFilter()::filter);

    filteredEngineCategories.predicateProperty().bind(
            Bindings.createObjectBinding(() -> getControl().getFilter()::filter,
                    getControl().searchTermProperty(),
                    getControl().showInstalledProperty(),
                    getControl().showNotInstalledProperty()));

    final EnginesSidebarToggleGroup categoryView = new EnginesSidebarToggleGroup(tr("Engines"),
            filteredEngineCategories);

    getControl().selectedEngineCategoryProperty().bind(categoryView.selectedElementProperty());

    return categoryView;
}
 
Example #25
Source File: EngineSubCategoryPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a {@link FilteredList} object of the engine versions by applying the {@link EnginesFilter} known to the
 * control
 *
 * @return A filtered list of the engine versions
 */
private ObservableList<EngineVersionDTO> createFilteredEngineVersions() {
    final EnginesFilter filter = getControl().getFilter();

    final EngineCategoryDTO engineCategory = getControl().getEngineCategory();
    final EngineSubCategoryDTO engineSubCategory = getControl().getEngineSubCategory();

    final FilteredList<EngineVersionDTO> filteredEngineVersions = FXCollections
            .observableArrayList(engineSubCategory.getPackages())
            .sorted(EngineSubCategoryDTO.comparator().reversed())
            .filtered(filter.createFilter(engineCategory, engineSubCategory));

    filteredEngineVersions.predicateProperty().bind(
            Bindings.createObjectBinding(() -> filter.createFilter(engineCategory, engineSubCategory),
                    filter.searchTermProperty(),
                    filter.selectedEngineCategoryProperty(),
                    filter.showInstalledProperty(),
                    filter.showNotInstalledProperty()));

    return filteredEngineVersions;
}
 
Example #26
Source File: ViewSquare.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the square view.
 * @param sh The model.
 */
ViewSquare(final Square sh) {
	super(sh);
	border.xProperty().bind(model.getPtAt(0).xProperty());
	border.yProperty().bind(model.getPtAt(0).yProperty());
	border.widthProperty().bind(Bindings.createDoubleBinding(model::getWidth, model.getPtAt(0).xProperty(), model.getPtAt(1).xProperty()));
	border.heightProperty().bind(Bindings.createDoubleBinding(model::getWidth, model.getPtAt(0).xProperty(), model.getPtAt(1).xProperty()));
	model.frameArcProperty().addListener(lineArcCall);
	border.boundsInLocalProperty().addListener(lineArcUp);
	lineArcCall.changed(model.frameArcProperty(), model.getLineArc(), model.getLineArc());
}
 
Example #27
Source File: ThemeManager.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param currentTheme The current theme
 */
public ThemeManager(ObjectProperty<Theme> currentTheme) {
    super();

    this.currentTheme = currentTheme;

    this.defaultCategoryIconsStylesheets = FXCollections.observableArrayList();
    this.defaultLibraryCategoryIconsStylesheets = FXCollections.observableArrayList();
    this.defaultEngineIconsStylesheets = FXCollections.observableArrayList();

    // the base stylesheets
    final ObservableList<String> baseStylesheets = FXCollections
            .observableList(getStylesheets(Themes.STANDARD));
    // the currently selected stylesheets (empty if the the selected theme is the standard theme)
    final ObservableList<String> currentStylesheets = CollectionBindings
            .mapToList(currentTheme, this::getNonStandardStylesheets);

    this.stylesheets = ConcatenatedList.create(
            defaultCategoryIconsStylesheets,
            defaultLibraryCategoryIconsStylesheets,
            defaultEngineIconsStylesheets,
            baseStylesheets,
            currentStylesheets);

    final ObjectBinding<Optional<URI>> currentWebEngineUri = ObjectBindings.map(currentTheme,
            theme -> theme.getResourceUri("description.css"));
    final StringBinding currentWebEngineStylesheet = StringBindings.map(currentWebEngineUri,
            uri -> uri.map(URI::toString).orElse(null));

    this.webEngineStylesheet = Bindings
            .when(Bindings.isNull(currentWebEngineStylesheet))
            .then(Themes.STANDARD.getResourceUri("description.css").map(URI::toString)
                    .orElseThrow(
                            () -> new IllegalStateException("Standard theme contains no \"description.css\" file")))
            .otherwise(currentWebEngineStylesheet);
}
 
Example #28
Source File: ExportCOCOController.java    From OpenLabeler with Apache License 2.0 5 votes vote down vote up
private void bindProperties() {
   ObjectMapper mapper = AppUtils.createJSONMapper();
   try {
      if (!Settings.getToolCOCOJson().isBlank()) {
         coco = mapper.readValue(Settings.getToolCOCOJson(), COCO.class);
      }
      if (coco == null) {
         coco = new COCO();
      }
      // Fields that can only accept numbers
      txtInfoYear.setTextFormatter(AppUtils.createNumberTextFormatter());
      txtLicenseId.setTextFormatter(AppUtils.createNumberTextFormatter());

      // COCO info section
      Bindings.bindBidirectional(txtInfoYear.textProperty(), coco.info.yearProperty, new NumberStringConverter("#"));
      txtInfoVersion.textProperty().bindBidirectional(coco.info.versionProperty);
      txtInfoDescription.textProperty().bindBidirectional(coco.info.descriptionProperty);
      txtInfoContributor.textProperty().bindBidirectional(coco.info.contributorProperty);
      txtInfoUrl.textProperty().bindBidirectional(coco.info.urlProperty);
      datePicker.valueProperty().bindBidirectional(coco.info.dateCreatedProperty);

      // COCO images
      rbUsePathInXml.selectedProperty().bindBidirectional(coco.usePathInXmlProperty);
      rbNameAsId.selectedProperty().bindBidirectional(coco.nameAsIdProperty);
      dirMedia.disableProperty().bindBidirectional(coco.usePathInXmlProperty);

      // COCO license section
      Bindings.bindBidirectional(txtLicenseId.textProperty(), coco.license.idProperty, new NumberStringConverter("#"));
      txtLicenseName.textProperty().bindBidirectional(coco.license.nameProperty);
      txtLicenseUrl.textProperty().bindBidirectional(coco.license.urlProperty);

      // Output
      chkFormatJSON.selectedProperty().bindBidirectional(coco.formatJSONProperty);
      fileOutput.textProperty().bindBidirectional(coco.outputProperty);
   } catch (Exception ex) {
      LOG.log(Level.WARNING, "Unable to initialize COCO info section", ex);
   }
}
 
Example #29
Source File: ViewBezierCurve.java    From latexdraw with GNU General Public License v3.0 5 votes vote down vote up
private Line createLine(final Point p1, final Point p2) {
	final Line line = new Line();
	line.startXProperty().bind(p1.xProperty());
	line.startYProperty().bind(p1.yProperty());
	line.endXProperty().bind(p2.xProperty());
	line.endYProperty().bind(p2.yProperty());
	line.strokeWidthProperty().bind(Bindings.createDoubleBinding(() -> model.getFullThickness() / 2d, model.thicknessProperty(),
		model.dbleBordSepProperty(), model.dbleBordProperty()));
	line.strokeProperty().bind(Bindings.createObjectBinding(() -> model.getLineColour().toJFX(), model.lineColourProperty()));
	line.setStrokeLineCap(StrokeLineCap.BUTT);
	line.getStrokeDashArray().clear();
	line.getStrokeDashArray().addAll(model.getDashSepBlack(), model.getDashSepWhite());
	return line;
}
 
Example #30
Source File: ReportsController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
@FXML public void fillSupplierChart() {
    
    supplierchart.setVisible(true);
    
    HashMap<String,String> supplierNames = admin.getSupplierNames();
    
    ArrayList<ArrayList<String>> suppliers = admin.getSupplierSummary();
    int noOfSuppliers = suppliers.get(0).size();
    
    ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
    for (int i = 0; i < noOfSuppliers; i++)
    {
        String supplierID = suppliers.get(0).get(i);
        int stocks = Integer.parseInt(suppliers.get(1).get(i));
        pieChartData.add(new PieChart.Data(supplierNames.get(supplierID), stocks));
    }
    //piechart.setLabelLineLength(20);
    
    pieChartData.forEach(data ->
            data.nameProperty().bind(
                    Bindings.concat(
                            data.getName(), " (", data.pieValueProperty(), ")"
                    )
            )
    );
    
    
    supplierchart.setLegendSide(Side.BOTTOM); 
    supplierchart.setLabelsVisible(true);
    supplierchart.setData(pieChartData);

}