Java Code Examples for javafx.util.StringConverter#toString()

The following examples show how to use javafx.util.StringConverter#toString() . 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: GlobalProperties.java    From FxDock with Apache License 2.0 6 votes vote down vote up
protected static <T> void store(GlobalProperty<T> p)
{
	try
	{
		String k = p.getName();
		T v = p.getValue();
		
		String s;
		if(v == null)
		{
			s = null;
		}
		else
		{
			StringConverter<T> c = p.getConverter();
			s = c.toString(v);
		}
		GlobalSettings.setString(k, s);
	}
	catch(Exception e)
	{
		Log.err(e);
	}
}
 
Example 2
Source File: ZonedDateTimeAxis.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
protected String getTickMarkLabel(ZonedDateTime datetime) {
    final StringConverter<ZonedDateTime> converter = getTickLabelFormatter();
    if (converter != null) {
        return converter.toString(datetime);
    }

    final DateTimeFormatter formatter;
    if (actualInterval.interval == ChronoUnit.YEARS && datetime.getMonth() == Month.JANUARY && datetime.getDayOfMonth() == 1) {
        formatter = DateTimeFormatter.ofPattern("yyyy");
    } else if (actualInterval.interval == ChronoUnit.MONTHS && datetime.getDayOfMonth() == 1) {
        formatter = DateTimeFormatter.ofPattern("MMM yy");
    } else {
        switch (actualInterval.interval) {
            case DAYS:
            case WEEKS:
            case HOURS:
            case MINUTES:
                formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
                break;
            case SECONDS:
                formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
                break;
            case MILLIS:
                formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL);
                break;
            default:
                formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
                break;
        }
    }
    return formatter.format(datetime);
}
 
Example 3
Source File: AbstractAxis.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * Get the string label name for a tick mark with the given value
 *
 * @param value The value to format into a tick label string
 * @return A formatted string for the given value
 */
@Override
public String getTickMarkLabel(final double value) {
    // convert value according to scale factor
    final double scaledValue = value / getUnitScaling();

    final StringConverter<Number> formatter = getTickLabelFormatter();
    if (formatter != null) {
        return formatter.toString(scaledValue);
    }
    // use AxisLabelFormatter based implementation
    return getAxisLabelFormatter().toString(scaledValue);
}
 
Example 4
Source File: JavaFXElementPropertyAccessor.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private String getChoiceBoxItemText(@SuppressWarnings("rawtypes")
ChoiceBox choiceBox, int index) {
    @SuppressWarnings("rawtypes")
    StringConverter converter = choiceBox.getConverter();
    String text = null;
    if (converter == null) {
        text = choiceBox.getItems().get(index).toString();
    } else {
        text = converter.toString(choiceBox.getItems().get(index));
    }
    return stripHTMLTags(text);
}
 
Example 5
Source File: JavaFXComboBoxCellElement.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public String _getValue() {
    StringConverter converter = getConverter();
    Object item = ((Cell) node).getItem();
    if (converter != null) {
        return converter.toString(item);
    }
    return item.toString();
}
 
Example 6
Source File: JavaFXChoiceBoxCellElement.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public String _getValue() {
    StringConverter converter = getConverter();
    Object item = ((Cell) node).getItem();
    if (converter != null) {
        return converter.toString(item);
    }
    return item.toString();
}
 
Example 7
Source File: RFXChoiceBoxTableCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    @SuppressWarnings("rawtypes")
    ChoiceBoxTableCell cell = (ChoiceBoxTableCell) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example 8
Source File: RFXTextFieldListCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    TextFieldListCell<?> cell = (TextFieldListCell<?>) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example 9
Source File: RFXTextFieldTableCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    TextFieldTableCell<?, ?> cell = (TextFieldTableCell<?, ?>) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example 10
Source File: RFXChoiceBoxTreeTableCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    @SuppressWarnings("rawtypes")
    ChoiceBoxTreeTableCell cell = (ChoiceBoxTreeTableCell) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example 11
Source File: RFXTextFieldTreeCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    TextFieldTreeCell<?> cell = (TextFieldTreeCell<?>) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example 12
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 13
Source File: RFXChoiceBoxListCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    @SuppressWarnings("rawtypes")
    ChoiceBoxListCell cell = (ChoiceBoxListCell) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example 14
Source File: RFXTextFieldTreeTableCell.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    TextFieldTreeTableCell<?, ?> cell = (TextFieldTreeTableCell<?, ?>) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
Example 15
Source File: CellUtils.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
    return converter == null ?
            cell.getItem() == null ? "" : cell.getItem().toString() :
            converter.toString(cell.getItem());
}
 
Example 16
Source File: OptionsDialog.java    From DeskChan with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
	return converter == null ? cell.getItem() == null ? "" : cell.getItem()
			.toString() : converter.toString(cell.getItem());
}
 
Example 17
Source File: CellUtiles.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
    return converter == null ?
        cell.getItem() == null ? "" : cell.getItem().toString() :
        converter.toString(cell.getItem());
}
 
Example 18
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 4 votes vote down vote up
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
    return converter == null ?
        cell.getItem() == null ? "" : cell.getItem().toString() :
        converter.toString(cell.getItem());
}
 
Example 19
Source File: LargeTextTreeTableCell.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
	return converter == null ? cell.getItem() == null ? "" : cell.getItem().toString()
			: converter.toString(cell.getItem());
}
 
Example 20
Source File: LargeTextTableCell.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
private static <T> String getItemText(Cell<T> cell, StringConverter<T> converter) {
	return converter == null ? cell.getItem() == null ? "" : cell.getItem().toString()
			: converter.toString(cell.getItem());
}