46 import javafx.scene.paint.Paint; 47 import javafx.scene.text.Font; 48 import javafx.util.Duration; 49 50 import com.sun.javafx.scene.layout.region.CornerRadiiConverter; 51 import com.sun.javafx.util.Logging; 52 import sun.util.logging.PlatformLogger; 53 import sun.util.logging.PlatformLogger.Level; 54 55 import java.io.DataInputStream; 56 import java.io.DataOutputStream; 57 import java.io.IOException; 58 import java.util.ArrayList; 59 import java.util.HashMap; 60 import java.util.List; 61 import java.util.Map; 62 import java.util.WeakHashMap; 63 64 65 /** 66 * StyleConverter converts {@code ParsedValue&tl;F,T>} from type F to type T. The 67 * {@link CssMetaData} API requires a {@code StyleConverter} which is used 68 * when computing a value for the {@see StyleableProperty}. There are 69 * a number of predefined converters which are accessible by the static 70 * methods of this class. 71 * 72 * F is the type of the parsed value, T is the converted type of 73 * the ParsedValueImpl. For example, a converter from String to Color would 74 * be declared 75 * <p> 76 * <code>public Color convert(ParsedValueImpl<String,Color> value, Font font)</code> 77 * </p> 78 * 79 * @see ParsedValue 80 * @see StyleableProperty 81 * @since JavaFX 8.0 82 */ 83 public class StyleConverter<F, T> { 84 85 /** 86 * Convert from the parsed CSS value to the target property type. 87 * 88 * @param value The {@link ParsedValue} to convert 89 * @param font The {@link Font} to use when converting a 90 * <a href="http://www.w3.org/TR/css3-values/#relative-lengths">relative</a> 91 * value. 92 */ 93 @SuppressWarnings("unchecked") 94 public T convert(ParsedValue<F,T> value, Font font) { 95 // unchecked! 96 return (T) value.getValue(); 97 } 98 | 46 import javafx.scene.paint.Paint; 47 import javafx.scene.text.Font; 48 import javafx.util.Duration; 49 50 import com.sun.javafx.scene.layout.region.CornerRadiiConverter; 51 import com.sun.javafx.util.Logging; 52 import sun.util.logging.PlatformLogger; 53 import sun.util.logging.PlatformLogger.Level; 54 55 import java.io.DataInputStream; 56 import java.io.DataOutputStream; 57 import java.io.IOException; 58 import java.util.ArrayList; 59 import java.util.HashMap; 60 import java.util.List; 61 import java.util.Map; 62 import java.util.WeakHashMap; 63 64 65 /** 66 * StyleConverter converts {@code ParsedValue<F,T>} 67 * from type {@code F} to type {@code T}. The 68 * {@link CssMetaData} API requires a {@code StyleConverter} which is used 69 * when computing a value for the {@see StyleableProperty}. There are 70 * a number of predefined converters which are accessible by the static 71 * methods of this class. 72 * 73 * @{code F} is the type of the parsed value and {code T} is the converted type of 74 * the ParsedValueImpl. For example, a converter from String to Color would 75 * be declared 76 * <p> 77 * <code>public Color convert(ParsedValueImpl<String,Color> value, Font font)</code> 78 * </p> 79 * 80 * @param <F> the type of the parsed value 81 * @param <T> the converted type of the ParsedValueImpl 82 * 83 * @see ParsedValue 84 * @see StyleableProperty 85 * @since JavaFX 8.0 86 */ 87 public class StyleConverter<F, T> { 88 89 /** 90 * Convert from the parsed CSS value to the target property type. 91 * 92 * @param value The {@link ParsedValue} to convert 93 * @param font The {@link Font} to use when converting a 94 * <a href="http://www.w3.org/TR/css3-values/#relative-lengths">relative</a> 95 * value. 96 */ 97 @SuppressWarnings("unchecked") 98 public T convert(ParsedValue<F,T> value, Font font) { 99 // unchecked! 100 return (T) value.getValue(); 101 } 102 |