mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
UIDefaultsLoader: reduced need for {float} in properties files and in CSS styles
This commit is contained in:
@@ -335,7 +335,7 @@ class UIDefaultsLoader
|
||||
throw new IllegalArgumentException( "property value type '" + newValue.getClass().getName() + "' not supported in references" );
|
||||
}
|
||||
|
||||
enum ValueType { UNKNOWN, STRING, BOOLEAN, CHARACTER, INTEGER, FLOAT, BORDER, ICON, INSETS, DIMENSION, COLOR, FONT,
|
||||
enum ValueType { UNKNOWN, STRING, BOOLEAN, CHARACTER, INTEGER, INTEGERORFLOAT, FLOAT, BORDER, ICON, INSETS, DIMENSION, COLOR, FONT,
|
||||
SCALEDINTEGER, SCALEDFLOAT, SCALEDINSETS, SCALEDDIMENSION, INSTANCE, CLASS, GRAYFILTER, NULL, LAZY }
|
||||
|
||||
private static ValueType[] tempResultValueType = new ValueType[1];
|
||||
@@ -468,7 +468,7 @@ class UIDefaultsLoader
|
||||
else if( key.endsWith( "Size" ) )
|
||||
valueType = ValueType.DIMENSION;
|
||||
else if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
||||
valueType = ValueType.INTEGER;
|
||||
valueType = ValueType.INTEGERORFLOAT;
|
||||
else if( key.endsWith( "Char" ) )
|
||||
valueType = ValueType.CHARACTER;
|
||||
else if( key.endsWith( "grayFilter" ) )
|
||||
@@ -484,6 +484,7 @@ class UIDefaultsLoader
|
||||
case BOOLEAN: return parseBoolean( value );
|
||||
case CHARACTER: return parseCharacter( value );
|
||||
case INTEGER: return parseInteger( value, true );
|
||||
case INTEGERORFLOAT:return parseIntegerOrFloat( value, true );
|
||||
case FLOAT: return parseFloat( value, true );
|
||||
case BORDER: return parseBorder( value, resolver, addonClassLoaders );
|
||||
case ICON: return parseInstance( value, addonClassLoaders );
|
||||
@@ -1160,6 +1161,20 @@ class UIDefaultsLoader
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Number parseIntegerOrFloat( String value, boolean reportError ) {
|
||||
try {
|
||||
return Integer.parseInt( value );
|
||||
} catch( NumberFormatException ex ) {
|
||||
try {
|
||||
return Float.parseFloat( value );
|
||||
} catch( NumberFormatException ex2 ) {
|
||||
if( reportError )
|
||||
throw new NumberFormatException( "invalid integer or float '" + value + "'" );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Float parseFloat( String value, boolean reportError ) {
|
||||
try {
|
||||
return Float.parseFloat( value );
|
||||
|
||||
@@ -226,8 +226,8 @@ ComboBox.buttonPressedArrowColor = @buttonPressedArrowColor
|
||||
#---- Component ----
|
||||
|
||||
Component.focusWidth = 0
|
||||
Component.innerFocusWidth = {float}0.5
|
||||
Component.innerOutlineWidth = {float}1
|
||||
Component.innerFocusWidth = 0.5
|
||||
Component.innerOutlineWidth = 1
|
||||
Component.arc = 5
|
||||
Component.minimumWidth = 64
|
||||
# allowed values: chevron or triangle
|
||||
@@ -626,7 +626,7 @@ TabbedPane.closeSize = 16,16
|
||||
TabbedPane.closeArc = 4
|
||||
TabbedPane.closeCrossPlainSize = {float}7.5
|
||||
TabbedPane.closeCrossFilledSize = $TabbedPane.closeCrossPlainSize
|
||||
TabbedPane.closeCrossLineWidth = {float}1
|
||||
TabbedPane.closeCrossLineWidth = 1
|
||||
|
||||
|
||||
#---- Table ----
|
||||
|
||||
Reference in New Issue
Block a user