@Override public IndicatorPosition convert(ParsedValue<String, IndicatorPosition> value, Font not_used) { String string = value.getValue().toUpperCase(); try { return IndicatorPosition.valueOf(string); } catch (IllegalArgumentException | NullPointerException exception) { return IndicatorPosition.LEFT; } }
@Override public DialogTransition convert(ParsedValue<String, DialogTransition> value, Font not_used) { String string = value.getValue(); try { return DialogTransition.valueOf(string); } catch (IllegalArgumentException | NullPointerException exception) { return DialogTransition.CENTER; } }
@Override public RipplerMask convert(ParsedValue<String, RipplerMask> value, Font notUsed) { String string = value.getValue(); try { return RipplerMask.valueOf(string); } catch (IllegalArgumentException | NullPointerException exception) { return RipplerMask.RECT; } }
@Override public ButtonType convert(ParsedValue<String, ButtonType> value, Font notUsedFont) { String string = value.getValue(); try { return ButtonType.valueOf(string); } catch (IllegalArgumentException | NullPointerException exception) { Logger.getLogger(ButtonTypeConverter.class.getName()).info(String.format("Invalid button type value '%s'", string)); return ButtonType.FLAT; } }
@Override public SimpleDateFormat convert(ParsedValue<String, DateFormat> value, Font not_used) { String str = value.getValue(); return new SimpleDateFormat(str); }
@Override public Double convert(ParsedValue<String, Double> value, Font not_used) { String str = value.getValue(); return Double.parseDouble(str); }
@Override public Integer convert(ParsedValue<String, Integer> value, Font not_used) { String str = value.getValue(); return Integer.parseInt(str); }
@Override public IndicatorPosition convert(ParsedValue<String, IndicatorPosition> value, Font not_used) { String string = value.getValue().toUpperCase(); try { return IndicatorPosition.valueOf(string); } catch (IllegalArgumentException | NullPointerException exception) { return IndicatorPosition.LEFT; } }
@Override public ButtonType convert(ParsedValue<String, ButtonType> value, Font notUsedFont) { String string = value.getValue(); try { return ButtonType.valueOf(string); } catch (IllegalArgumentException | NullPointerException exception) { Logger.getLogger(ButtonTypeConverter.class.getName()).info(String.format("Invalid button type value '%s'", string)); return ButtonType.FLAT; } }
@Override public DialogTransition convert(ParsedValue<String, DialogTransition> value, Font not_used) { String string = value.getValue(); try { return DialogTransition.valueOf(string); } catch (IllegalArgumentException | NullPointerException exception) { return DialogTransition.CENTER; } }
@Override public RipplerMask convert(ParsedValue<String, RipplerMask> value, Font notUsed) { String string = value.getValue(); try { return RipplerMask.valueOf(string); } catch (IllegalArgumentException | NullPointerException exception) { return RipplerMask.RECT; } }
@Override public FontIcon convert(ParsedValue<String, FontIcon> value, Font font) { String v = value.getValue(); if( v == null ) { return FontIcon.UNKNOWN; } return FontIcon.create(v).orElse(FontIcon.UNKNOWN); }
@Override public MacOSDefaultIcons convert(ParsedValue<String, MacOSDefaultIcons> value, Font font) { String str = value.getValue(); if (str == null || str.isEmpty() || "null".equals(str)) { return null; } try { return MacOSDefaultIcons.valueOf(str); } catch (final IllegalArgumentException e) { // TODO: use logger here System.err.println("not a Mac Icon: " + value); return MacOSDefaultIcons.RIGHT; } }
@Override public FontIcon convert(ParsedValue<String, FontIcon> value, Font font) { String v = value.getValue(); // v = Utils.convertUnicode(v); if (v.length() == 1) { char c = v.charAt(0); return FontIcon.create(c); } else { return FontIcon.create(v); } }
@SuppressWarnings("null") @Override public DecorationStrategy convert(ParsedValue<ParsedValue<?, DecorationStrategy>, DecorationStrategy> value, Font font) { String definition = value.getValue() + ""; //$NON-NLS-1$ if (FACTORIES == null) { FACTORIES = Util.lookupServiceList(getClass(), DecorationStrategyFactory.class).stream().sorted((f1, f2) -> -1 * Integer.compare(f1.getRanking(), f2.getRanking())).collect(Collectors.toMap(f -> f.getDecorationStrategyName(), f -> f)); } String type; if (definition.contains("(")) { //$NON-NLS-1$ type = definition.substring(0, definition.indexOf('(')); } else { type = definition + ""; //$NON-NLS-1$ } DecorationStrategyFactory strategy = FACTORIES.get(type); if (strategy != null) { return strategy.create(definition.contains("(") ? definition.substring(definition.indexOf('(') + 1, definition.lastIndexOf(')')) : null); //$NON-NLS-1$ } return null; } }
@SuppressWarnings("null") @Override public DecorationStrategy convert(ParsedValue<ParsedValue<?, DecorationStrategy>, DecorationStrategy> value, Font font) { String definition = value.getValue() + ""; //$NON-NLS-1$ if (FACTORIES == null) { FACTORIES = Util.lookupServiceList(getClass(), DecorationStrategyFactory.class).stream().sorted((f1, f2) -> -1 * Integer.compare(f1.getRanking(), f2.getRanking())).collect(Collectors.toMap(f -> f.getDecorationStrategyName(), f -> f)); } String type; if (definition.contains("(")) { //$NON-NLS-1$ type = definition.substring(0, definition.indexOf('(')); } else { type = definition + ""; //$NON-NLS-1$ } DecorationStrategyFactory strategy = FACTORIES.get(type); if (strategy != null) { return strategy.create(definition.contains("(") ? definition.substring(definition.indexOf('(') + 1, definition.lastIndexOf(')')) : null); //$NON-NLS-1$ } return null; } }