javafx.util.StringConverter Java Examples

The following examples show how to use javafx.util.StringConverter. 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: CellUtils.java    From AsciidocFX with Apache License 2.0 6 votes vote down vote up
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    if (textField != null) {
        textField.setText(getItemText(cell, converter));
    }
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
Example #2
Source File: DebugView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void addGroup(String title, ObservableList<Class<? extends Task>> list) {
    final Tuple2<Label, ComboBox<Class<? extends Task>>> selectTaskToIntercept =
            addTopLabelComboBox(root, ++rowIndex, title, "Select task to intercept", 15);
    ComboBox<Class<? extends Task>> comboBox = selectTaskToIntercept.second;
    comboBox.setVisibleRowCount(list.size());
    comboBox.setItems(list);
    comboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(Class<? extends Task> item) {
            return item.getSimpleName();
        }

        @Override
        public Class<? extends Task> fromString(String s) {
            return null;
        }
    });
    comboBox.setOnAction(event -> Task.taskToIntercept = comboBox.getSelectionModel().getSelectedItem());
}
 
Example #3
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 #4
Source File: Converters.java    From FxDock with Apache License 2.0 6 votes vote down vote up
public static StringConverter<Object> OBJECT()
{
	if(objectConverter == null)
	{
		objectConverter = new StringConverter<Object>()
		{
			public String toString(Object x)
			{
				return x == null ? null : x.toString();
			}

			public Object fromString(String s)
			{
				return s;
			}
		};
	}
	return objectConverter;
}
 
Example #5
Source File: ItemRemoveListCell.java    From oim-fx with MIT License 6 votes vote down vote up
@Override
    public void updateItem(T item, boolean empty) {
        super.updateItem(item, empty);
        if (!empty) {
//        	removeButton.setOnAction(new EventHandler<ActionEvent>() {
//                @Override
//                public void handle(ActionEvent event) {
//                    if (null != removeValueAction) {
//                    	removeValueAction.value(getItem());;
//                    }
//                }
//            });
        	Button b=new Button("(x)");
        	b.setOnAction(a->{
        		System.out.println(888);
        	});
            StringConverter<T> c = getConverter();
            //setGraphic(b);
            setText(c != null ? c.toString(item) : (item == null ? "" : item.toString()));
        } else {
            //setGraphic(null);
            setText(null);
        }
    }
 
Example #6
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 6 votes vote down vote up
static <T> TextField createTextField(final Cell<T> cell, final StringConverter<T> converter) {
    final TextField textField = new TextField(getItemText(cell, converter));

    // Use onAction here rather than onKeyReleased (with check for Enter),
    // as otherwise we encounter RT-34685
    textField.setOnAction(event -> {
        if (converter == null) {
            throw new IllegalStateException(
                    "Attempting to convert text input into Object, but provided "
                            + "StringConverter is null. Be sure to set a StringConverter "
                            + "in your cell factory.");
        }
        cell.commitEdit(converter.fromString(textField.getText()));
        event.consume();
    });
    textField.setOnKeyReleased(t -> {
        if (t.getCode() == KeyCode.ESCAPE) {
            cell.cancelEdit();
            t.consume();
        }
    });
    return textField;
}
 
Example #7
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 6 votes vote down vote up
static <T> void startEdit(final Cell<T> cell,
                          final StringConverter<T> converter,
                          final HBox hbox,
                          final Node graphic,
                          final TextField textField) {
    if (textField != null) {
        textField.setText(getItemText(cell, converter));
    }
    cell.setText(null);

    if (graphic != null) {
        hbox.getChildren().setAll(graphic, textField);
        cell.setGraphic(hbox);
    } else {
        cell.setGraphic(textField);
    }

    textField.selectAll();

    // requesting focus so that key input can immediately go into the
    // TextField (see RT-28132)
    textField.requestFocus();
}
 
Example #8
Source File: ItemListCell.java    From oim-fx with MIT License 6 votes vote down vote up
public ItemListCell(ExecuteAction executeAction, final StringConverter<T> converter) {
    setConverter(converter);
    this.executeAction = executeAction;
    this.button = new Button();
    button.getStyleClass().clear();
    button.setMinHeight(20);
    button.setMinWidth(20);

    //Image image = ImageBox.getImageClassPath("/resources/common/imagse/close/1_cancel_button_hover.png");
    //button.setGraphic(new ImageView(image));
    
    button.setText("X");
    setAlignment(Pos.CENTER_LEFT);
    setContentDisplay(ContentDisplay.LEFT);
    setGraphic(null);
}
 
Example #9
Source File: InterfaceSelectDialogController.java    From trex-stateless-gui with Apache License 2.0 6 votes vote down vote up
private void initComboBox() {
    interfacesComboBox.setItems(FXCollections.observableList(new ArrayList<>(interfacesInfo.values())));
    interfacesComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        propertiesTableView.setItems(FXCollections.observableList(new ArrayList<>(newValue.getProperties().entrySet())));
    });

    interfacesComboBox.setConverter(new StringConverter<InterfaceInfo>() {
        @Override
        public String toString(InterfaceInfo object) {
            return object.Slot_str;
        }

        @Override
        public InterfaceInfo fromString(String string) {
            return null;
        }
    });
    interfacesComboBox.getSelectionModel().select(0);
}
 
Example #10
Source File: AssetFeeView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void initialize() {
    addTitledGroupBg(root, gridRow, 3, Res.get("dao.burnBsq.header"));

    assetComboBox = FormBuilder.addComboBox(root, gridRow,
            Res.get("dao.burnBsq.selectAsset"), Layout.FIRST_ROW_DISTANCE);
    assetComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(StatefulAsset statefulAsset) {
            return CurrencyUtil.getNameAndCode(statefulAsset.getAsset().getTickerSymbol());
        }

        @Override
        public StatefulAsset fromString(String string) {
            return null;
        }
    });

    feeAmountInputTextField = addInputTextField(root, ++gridRow, Res.get("dao.burnBsq.fee"));
    feeAmountInputTextField.setValidator(bsqValidator);

    trialPeriodTextField = FormBuilder.addTopLabelTextField(root, ++gridRow, Res.get("dao.burnBsq.trialPeriod")).second;

    payFeeButton = addButtonAfterGroup(root, ++gridRow, Res.get("dao.burnBsq.payFee"));

    tableView = FormBuilder.addTableViewWithHeader(root, ++gridRow, Res.get("dao.burnBsq.allAssets"), 20, "last");
    createColumns();
    tableView.setItems(sortedList);

    createListeners();
}
 
Example #11
Source File: LanguageVersionRangeSlider.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public LanguageVersionRangeSlider() {

        setMin(NO_MIN);
        setBlockIncrement(1);
        setMajorTickUnit(1);
        setMinorTickCount(0);
        setSnapToTicks(true);

        currentLanguage.values().distinct().subscribe(this::initLanguage);

        StringConverter<Number> converter = DesignerUtil.stringConverter(
            num -> {
                int n = num.intValue();
                if (n < 0) {
                    return NO_MIN_STR;
                } else if (n >= curVersions.size()) {
                    return NO_MAX_STR;
                } else {
                    return curVersions.get(n).getShortName();
                }
            },
            ver -> {
                switch (ver) {
                case NO_MIN_STR:
                    return -1;
                case NO_MAX_STR:
                    return curVersions.size();
                default:
                    LanguageVersion withName = curVersions.stream().filter(lv -> lv.getShortName().equals(ver)).findFirst().get();
                    return curVersions.indexOf(withName);
                }
            }
        );

        setLabelFormatter(converter);


    }
 
Example #12
Source File: DesignerUtil.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <T> StringConverter<T> stringConverter(Function<T, String> toString, Function<String, T> fromString) {
    return new StringConverter<T>() {
        @Override
        public String toString(T object) {
            return toString.apply(object);
        }


        @Override
        public T fromString(String string) {
            return fromString.apply(string);
        }
    };
}
 
Example #13
Source File: SpinnerAutoCommit.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void commitEditorText() {
  if (!isEditable())
    return;
  String text = getEditor().getText();
  SpinnerValueFactory<T> valueFactory = getValueFactory();
  if (valueFactory != null) {
    StringConverter<T> converter = valueFactory.getConverter();
    if (converter != null) {
      T value = converter.fromString(text);
      valueFactory.setValue(value);
    }
  }
}
 
Example #14
Source File: CellUtiles.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final ComboBox<T> comboBox) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (comboBox != null) {
                comboBox.getSelectionModel().select(cell.getItem());
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, comboBox);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(comboBox);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
Example #15
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
/***************************************************************************
 *                                                                         *
 * TextField convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final TextField textField) {
    updateItem(cell, converter, null, null, textField);
}
 
Example #16
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
/***************************************************************************
 *                                                                         *
 * ChoiceBox convenience                                                   *
 *                                                                         *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final ChoiceBox<T> choiceBox) {
    updateItem(cell, converter, null, null, choiceBox);
}
 
Example #17
Source File: AssetsForm.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void addTradeCurrencyComboBox() {
    currencyComboBox = FormBuilder.<TradeCurrency>addLabelAutocompleteComboBox(gridPane, ++gridRow, Res.get("payment.altcoin"),
            Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
    currencyComboBox.setPromptText(Res.get("payment.select.altcoin"));
    currencyComboBox.setButtonCell(getComboBoxButtonCell(Res.get("payment.select.altcoin"), currencyComboBox));

    currencyComboBox.getEditor().focusedProperty().addListener(observable ->
            currencyComboBox.setPromptText(""));

    ((AutocompleteComboBox<TradeCurrency>) currencyComboBox).setAutocompleteItems(
            CurrencyUtil.getActiveSortedCryptoCurrencies(assetService, filterManager));
    currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 10));

    currencyComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(TradeCurrency tradeCurrency) {
            return tradeCurrency != null ? tradeCurrency.getNameAndCode() : "";
        }

        @Override
        public TradeCurrency fromString(String s) {
            return currencyComboBox.getItems().stream().
                    filter(item -> item.getNameAndCode().equals(s)).
                    findAny().orElse(null);
        }
    });

    ((AutocompleteComboBox<?>) currencyComboBox).setOnChangeConfirmed(e -> {
        addressInputTextField.resetValidation();
        addressInputTextField.validate();
        paymentAccount.setSingleTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
        updateFromInputs();
    });
}
 
Example #18
Source File: ConfigurationUIController.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
private Node buildDynamicSelectComponent(ConfigNode node, String settingName, Serializable value) {
    try {
        DynamicSelection sel = (DynamicSelection) node.subject.getClass().getField(settingName).get(node.subject);
        ChoiceBox widget = new ChoiceBox(FXCollections.observableList(new ArrayList(sel.getSelections().keySet())));
        widget.setMinWidth(175.0);
        widget.setConverter(new StringConverter() {
            @Override
            public String toString(Object object) {
                return (String) sel.getSelections().get(object);
            }
            
            @Override
            public Object fromString(String string) {
                return sel.findValueByMatch(string);
            }
        });
        Object selected = value == null ? null : widget.getConverter().fromString(String.valueOf(value));
        if (selected == null) {
            widget.getSelectionModel().selectFirst();
        } else {
            widget.setValue(selected);
        }
        widget.valueProperty().addListener((Observable e) -> {
            node.setFieldValue(settingName, widget.getConverter().toString(widget.getValue()));
        });
        return widget;
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
        Logger.getLogger(ConfigurationUIController.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
}
 
Example #19
Source File: StateRepartitionTimelineChart.java    From jstackfx with Apache License 2.0 5 votes vote down vote up
public StateRepartitionTimelineChart() {
    super(new NumberAxis(), new NumberAxis());

    this.xAxis = (NumberAxis) getXAxis();
    this.yAxis = (NumberAxis) getYAxis();

    this.xAxis.setTickLabelFormatter(new StringConverter<Number>() {
        @Override
        public String toString(Number object) {
            if(object == null) return null;
            else {
                return DATE_TIME_FORMATTER_OUTPUT.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(object.longValue()), ZoneId.systemDefault()));
            }
        }

        @Override
        public Number fromString(String string) {
            if(string == null || string.isEmpty()) return null;
            else {
                return LocalDateTime.parse(string, DATE_TIME_FORMATTER_OUTPUT).toInstant(ZoneOffset.ofTotalSeconds(0)).toEpochMilli();
            }
        }
    });

    this.initializeDumpTimelineProperty();
    this.initializeSeries();
}
 
Example #20
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final HBox hbox,
                           final Node graphic,
                           final ComboBox<T> comboBox) {
    if (cell.isEmpty()) {
        cell.setText(null);
        cell.setGraphic(null);
    } else {
        if (cell.isEditing()) {
            if (comboBox != null) {
                comboBox.getSelectionModel().select(cell.getItem());
            }
            cell.setText(null);

            if (graphic != null) {
                hbox.getChildren().setAll(graphic, comboBox);
                cell.setGraphic(hbox);
            } else {
                cell.setGraphic(comboBox);
            }
        } else {
            cell.setText(getItemText(cell, converter));
            cell.setGraphic(graphic);
        }
    }
}
 
Example #21
Source File: CreateWorkspaceDialog.java    From milkman with MIT License 5 votes vote down vote up
public void showAndWait(List<WorkspaceSynchronizer> synchronizers, Toaster toaster) {
	this.toaster = toaster;
	JFXDialogLayout content = new CreateWorkspaceDialogFxml(this);
	synchronizers.forEach(i -> syncSelector.getItems().add(i.getDetailFactory()));
	
	//default to first item
	if (syncSelector.getItems().size() > 0) {
		SynchronizationDetailFactory defaultSync = syncSelector.getItems().get(0);
		syncSelector.setValue(defaultSync);
		syncDetailsArea.getChildren().add(defaultSync.getSyncDetailsControls());
		selectedSynchronizer = defaultSync;
	}
	
	syncSelector.setConverter(new StringConverter<SynchronizationDetailFactory>() {
		
		@Override
		public String toString(SynchronizationDetailFactory object) {
			return object.getName();
		}
		
		@Override
		public SynchronizationDetailFactory fromString(String string) {
			return null;
		}
	});
	syncSelector.getSelectionModel().selectedItemProperty().addListener((obs, o, v) -> {
		if (o != v && v != null) {
			selectedSynchronizer = v;
			syncDetailsArea.getChildren().clear();
			syncDetailsArea.getChildren().add(v.getSyncDetailsControls());
		} 
	});
	dialog = FxmlUtil.createDialog(content);
	dialog.showAndWait();
}
 
Example #22
Source File: ExportDialog.java    From milkman with MIT License 5 votes vote down vote up
public void showAndWait(List<Exporter<T>> exporters, Templater templater, Toaster toaster, T objToExport) {
	this.templater = templater;
	this.toaster = toaster;
	this.objToExport = objToExport;
	JFXDialogLayout content = new ExportDialogFxml(this);
	exportSelector.setPromptText("Select Exporter");
	exporters.forEach(exportSelector.getItems()::add);
	exportSelector.setConverter(new StringConverter<Exporter<T>>() {
		
		@Override
		public String toString(Exporter<T> object) {
			return object.getName();
		}
		
		@Override
		public Exporter<T> fromString(String string) {
			return null;
		}
	});
	exportSelector.getSelectionModel().selectedItemProperty().addListener((obs, o, v) -> {
		if (o != v && v != null) {
			selectedExporter = v;
			exportArea.getChildren().clear();
			exportArea.getChildren().add(v.getRoot(objToExport, templater));
			exportBtn.setDisable(v.isAdhocExporter());
		} 
	});
	dialog = FxmlUtil.createDialog(content);
	dialog.showAndWait();
}
 
Example #23
Source File: JFXComboBox.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private boolean updateDisplayText(ListCell<T> cell, T item, boolean empty) {
    if (empty) {
        // create empty cell
        if (cell == null) {
            return true;
        }
        cell.setGraphic(null);
        cell.setText(null);
        return true;
    } else if (item instanceof Node) {
        Node currentNode = cell.getGraphic();
        Node newNode = (Node) item;
        //  create a node from the selected node of the listview
        //  using JFXComboBox {@link #nodeConverterProperty() NodeConverter})
        NodeConverter<T> nc = this.getNodeConverter();
        Node node = nc == null ? null : nc.toNode(item);
        if (currentNode == null || !currentNode.equals(newNode)) {
            cell.setText(null);
            cell.setGraphic(node == null ? newNode : node);
        }
        return node == null;
    } else {
        // run item through StringConverter if it isn't null
        StringConverter<T> c = this.getConverter();
        String s = item == null ? this.getPromptText() : (c == null ? item.toString() : c.toString(item));
        cell.setText(s);
        cell.setGraphic(null);
        return s == null || s.isEmpty();
    }
}
 
Example #24
Source File: CategoryAxis.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * The ordered list of categories plotted on this axis. This is set automatically based on the charts data if
 * autoRanging is true. If the application sets the categories then auto ranging is turned off. If there is an
 * attempt to add duplicate entry into this list, an {@link IllegalArgumentException} is thrown. setting the
 * category via axis forces the axis' category, setting the axis categories to null forces the dataset's category
 *
 * @param categoryList the category list
 */
public void setCategories(final ObservableList<String> categoryList) {
    if (categoryList == null) {
        forceAxisCategories = false;
        setCategories(FXCollections.<String>observableArrayList());
        return;
    }

    this.setMaxMajorTickLabelCount(categoryList.size() + 1); // number of categories + unknown category
    setTickLabelFormatter(new StringConverter<Number>() {
        @Override
        public Number fromString(String string) {
            for (int i = 0; i < getCategories().size(); i++) {
                if (getCategories().get(i).equalsIgnoreCase(string)) {
                    return i;
                }
            }
            throw new IllegalArgumentException("Category not found.");
        }

        @Override
        public String toString(Number object) {
            final int index = Math.round(object.floatValue());
            if (index < 0 || index >= getCategories().size()) {
                return "unknown category";
            }
            return getCategories().get(index);
        }
    });
    categories.set(categoryList);

    requestAxisLayout();
}
 
Example #25
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
private static <T> void tryComboBoxCommit(ComboBox<T> comboBox, Cell<T> cell) {
    StringConverter<T> sc = comboBox.getConverter();
    if (comboBox.isEditable() && sc != null) {
        T value = sc.fromString(comboBox.getEditor().getText());
        cell.commitEdit(value);
    } else {
        cell.commitEdit(comboBox.getValue());
    }
}
 
Example #26
Source File: RFXChoiceBoxTreeCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    @SuppressWarnings("rawtypes")
    ChoiceBoxTreeCell cell = (ChoiceBoxTreeCell) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example #27
Source File: CellUtils.java    From AsciidocFX with Apache License 2.0 5 votes vote down vote up
/***************************************************************************
 * *
 * TextField convenience                                                   *
 * *
 **************************************************************************/

static <T> void updateItem(final Cell<T> cell,
                           final StringConverter<T> converter,
                           final TextField textField) {
    updateItem(cell, converter, null, null, textField);
}
 
Example #28
Source File: ClientLoginNode.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
private void initialize() {

        nextbutton.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_PLAY, 18.0).styleClass("icon-fill").build());

        adddeviceunit.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_FILE_ALT, 18.0).styleClass("icon-fill").build());
        adddeviceunit.setText(resources.getString("title.new"));
        
        removedeviceunit.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_TRASH_ALT, 18.0).styleClass("icon-fill").build());
        updeviceunit.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_CHEVRON_UP, 18.0).styleClass("icon-fill").build());
        downdeviceunit.setGraphic(IconBuilder.create(IconFontGlyph.FA_SOLID_CHEVRON_DOWN, 18.0).styleClass("icon-fill").build());

        devicesunitsselection.selectedItemProperty().addListener((ObservableValue<? extends TopicInfo> ov, TopicInfo old_val, TopicInfo new_val) -> {
            updateDevicesUnitsList();
        });
        updateDevicesUnitsList();
        
        skins.setConverter(new StringConverter<Style>() {
            @Override
            public String toString(Style style) {
                return resources.getString("style." + style.name());
            }
            @Override
            public Style fromString(String value) {
                return null;
            }
        });
        skins.getItems().addAll(Style.values());
        skins.getSelectionModel().selectedItemProperty().addListener((ov, old_val, new_val) -> {
            if (!updating) {
                Style.changeStyle(MessageUtils.getRoot(rootpane), new_val);
            }
        });
    }
 
Example #29
Source File: AbstractDataFormattingPlugin.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private static StringConverter<Number> createDefaultFormatter(final Axis axis) {
    // if (axis instanceof Axis) {
    // final de.gsi.chart.axes.spi.format.DefaultFormatter numberConverter
    // = new
    // de.gsi.chart.axes.spi.format.DefaultFormatter(
    // axis);
    // return numberConverter;
    // }
    // if (axis instanceof NumberAxis) { //TODO: re-enable
    // return (StringConverter<Number>) new
    // NumberAxis.DefaultFormatter((NumberAxis) axis);
    // }
    return new AbstractDataFormattingPlugin.DefaultFormatter<>();
}
 
Example #30
Source File: SupplyView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private StringConverter<Number> getTimestampTickLabelFormatter(String datePattern) {
    return new StringConverter<>() {
        @Override
        public String toString(Number timestamp) {
            LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(timestamp.longValue(),
                    0, OffsetDateTime.now(ZoneId.systemDefault()).getOffset());
            return localDateTime.format(DateTimeFormatter.ofPattern(datePattern, GlobalSettings.getLocale()));
        }

        @Override
        public Number fromString(String string) {
            return 0;
        }
    };
}