diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java index b7fdad8e..66460520 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/UIDefaultsLoader.java @@ -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 ); diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index ebbb9296..6b574866 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -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 ---- diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/TestUIDefaultsLoader.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/TestUIDefaultsLoader.java index eb9de8e7..4faaf965 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/TestUIDefaultsLoader.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/TestUIDefaultsLoader.java @@ -56,7 +56,7 @@ public class TestUIDefaultsLoader assertEquals( 123, UIDefaultsLoader.parseValue( "dummy", "123", null ) ); assertEquals( 123, UIDefaultsLoader.parseValue( "dummyWidth", "123", null ) ); assertEquals( 1.23f, UIDefaultsLoader.parseValue( "dummy", "1.23", null ) ); - assertEquals( 1.23f, UIDefaultsLoader.parseValue( "dummyWidth", "{float}1.23", null ) ); + assertEquals( 1.23f, UIDefaultsLoader.parseValue( "dummyWidth", "1.23", null ) ); assertEquals( new Insets( 2,2,2,2 ), UIDefaultsLoader.parseValue( "dummyInsets", "2,2,2,2", null ) ); assertEquals( new Dimension( 2,2 ), UIDefaultsLoader.parseValue( "dummySize", "2,2", null ) ); diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java index ef273c83..23a598d9 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/ui/TestFlatStyling.java @@ -201,7 +201,7 @@ public class TestFlatStyling ui.applyStyle( b, "help.focusWidth: 2" ); ui.applyStyle( b, "help.focusColor: #fff" ); - ui.applyStyle( b, "help.innerFocusWidth: {float}0.5" ); + ui.applyStyle( b, "help.innerFocusWidth: 0.5" ); ui.applyStyle( b, "help.borderWidth: 1" ); ui.applyStyle( b, "help.borderColor: #fff" ); @@ -869,7 +869,7 @@ public class TestFlatStyling ui.applyStyle( "closeArc: 4" ); ui.applyStyle( "closeCrossPlainSize: {float}7.5" ); ui.applyStyle( "closeCrossFilledSize: {float}7.5" ); - ui.applyStyle( "closeCrossLineWidth: {float}1" ); + ui.applyStyle( "closeCrossLineWidth: 1" ); ui.applyStyle( "closeBackground: #fff" ); ui.applyStyle( "closeForeground: #fff" ); ui.applyStyle( "closeHoverBackground: #fff" ); @@ -1124,7 +1124,7 @@ public class TestFlatStyling applyStyle.accept( "default.borderWidth: 2" ); applyStyle.accept( "toolbar.margin: 1,2,3,4" ); applyStyle.accept( "toolbar.spacingInsets: 1,2,3,4" ); - applyStyle.accept( "toolbar.focusWidth: {float}1.5" ); + applyStyle.accept( "toolbar.focusWidth: 1.5" ); applyStyle.accept( "arc: 6" ); } @@ -1146,8 +1146,8 @@ public class TestFlatStyling private void flatBorder( Consumer applyStyle ) { applyStyle.accept( "focusWidth: 2" ); - applyStyle.accept( "innerFocusWidth: {float}0.5" ); - applyStyle.accept( "innerOutlineWidth: {float}1.5" ); + applyStyle.accept( "innerFocusWidth: 0.5" ); + applyStyle.accept( "innerOutlineWidth: 1.5" ); applyStyle.accept( "focusColor: #fff" ); applyStyle.accept( "borderColor: #fff" ); applyStyle.accept( "disabledBorderColor: #fff" ); diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt index 66157fbd..cbb0c791 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarculaLaf_1.8.0.txt @@ -38,7 +38,7 @@ - Component.innerFocusWidth 0.5 + Component.innerFocusWidth 0 -- Component.innerOutlineWidth 1.0 +- Component.innerOutlineWidth 1 + Component.innerOutlineWidth 0 diff --git a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt index 4cb864f1..78832f2e 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatDarkLaf_1.8.0.txt @@ -234,7 +234,7 @@ Component.focusedBorderColor #446e9e HSL 212 40 44 javax.swing.plaf.Colo Component.grayFilter [lazy] [unknown type] com.formdev.flatlaf.util.GrayFilter Component.hideMnemonics true Component.innerFocusWidth 0.5 -Component.innerOutlineWidth 1.0 +Component.innerOutlineWidth 1 Component.linkColor #579bf6 HSL 214 90 65 javax.swing.plaf.ColorUIResource [UI] Component.minimumWidth 64 Component.warning.borderColor #725627 HSL 38 49 30 javax.swing.plaf.ColorUIResource [UI] @@ -1000,7 +1000,7 @@ TabbedPane.buttonInsets 2,1,2,1 javax.swing.plaf.InsetsUIResource [UI] TabbedPane.buttonPressedBackground #282a2c HSL 210 5 16 com.formdev.flatlaf.util.DerivedColor [UI] darken(8%) TabbedPane.closeArc 4 TabbedPane.closeCrossFilledSize 7.5 -TabbedPane.closeCrossLineWidth 1.0 +TabbedPane.closeCrossLineWidth 1 TabbedPane.closeCrossPlainSize 7.5 TabbedPane.closeForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI] TabbedPane.closeHoverBackground #484c4e HSL 200 4 29 com.formdev.flatlaf.util.DerivedColor [UI] lighten(5% autoInverse) diff --git a/flatlaf-testing/dumps/uidefaults/FlatIntelliJLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatIntelliJLaf_1.8.0.txt index d6580222..80784f67 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatIntelliJLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatIntelliJLaf_1.8.0.txt @@ -69,7 +69,7 @@ - Component.innerFocusWidth 0.5 + Component.innerFocusWidth 0 -- Component.innerOutlineWidth 1.0 +- Component.innerOutlineWidth 1 + Component.innerOutlineWidth 0 diff --git a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt index 9c078938..ecfb1aac 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatLightLaf_1.8.0.txt @@ -238,7 +238,7 @@ Component.focusedBorderColor #89b0d4 HSL 209 47 68 javax.swing.plaf.Colo Component.grayFilter [lazy] [unknown type] com.formdev.flatlaf.util.GrayFilter Component.hideMnemonics true Component.innerFocusWidth 0.5 -Component.innerOutlineWidth 1.0 +Component.innerOutlineWidth 1 Component.linkColor #236db2 HSL 209 67 42 javax.swing.plaf.ColorUIResource [UI] Component.minimumWidth 64 Component.warning.borderColor #fed284 HSL 38 98 76 javax.swing.plaf.ColorUIResource [UI] @@ -1005,7 +1005,7 @@ TabbedPane.buttonInsets 2,1,2,1 javax.swing.plaf.InsetsUIResource [UI] TabbedPane.buttonPressedBackground #d9d9d9 HSL 0 0 85 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse) TabbedPane.closeArc 4 TabbedPane.closeCrossFilledSize 7.5 -TabbedPane.closeCrossLineWidth 1.0 +TabbedPane.closeCrossLineWidth 1 TabbedPane.closeCrossPlainSize 7.5 TabbedPane.closeForeground #8c8c8c HSL 0 0 55 javax.swing.plaf.ColorUIResource [UI] TabbedPane.closeHoverBackground #bfbfbf HSL 0 0 75 com.formdev.flatlaf.util.DerivedColor [UI] darken(20% autoInverse) diff --git a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt index d2eb2d03..ce09c3c9 100644 --- a/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt +++ b/flatlaf-testing/dumps/uidefaults/FlatTestLaf_1.8.0.txt @@ -234,7 +234,7 @@ Component.focusedBorderColor #466d94 HSL 210 36 43 javax.swing.plaf.Colo Component.grayFilter [lazy] [unknown type] com.formdev.flatlaf.util.GrayFilter Component.hideMnemonics true Component.innerFocusWidth 0.5 -Component.innerOutlineWidth 1.0 +Component.innerOutlineWidth 1 Component.minimumWidth 64 @@ -1006,7 +1006,7 @@ TabbedPane.buttonInsets 2,1,2,1 javax.swing.plaf.InsetsUIResource [UI] TabbedPane.buttonPressedBackground #ffc800 HSL 47 100 50 javax.swing.plaf.ColorUIResource [UI] TabbedPane.closeArc 999 TabbedPane.closeCrossFilledSize 6.5 -TabbedPane.closeCrossLineWidth 2.0 +TabbedPane.closeCrossLineWidth 2 TabbedPane.closeCrossPlainSize 12.0 TabbedPane.closeForeground #ff0000 HSL 0 100 50 javax.swing.plaf.ColorUIResource [UI] TabbedPane.closeHoverBackground #aa0000 HSL 0 100 33 javax.swing.plaf.ColorUIResource [UI] diff --git a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties index d808a172..ba5dd9fd 100644 --- a/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties +++ b/flatlaf-testing/src/main/resources/com/formdev/flatlaf/testing/FlatTestLaf.properties @@ -344,7 +344,7 @@ TabbedPane.closeSize = 16,16 TabbedPane.closeArc = 999 TabbedPane.closeCrossPlainSize = {float}12 TabbedPane.closeCrossFilledSize = {float}6.5 -TabbedPane.closeCrossLineWidth = {float}2 +TabbedPane.closeCrossLineWidth = 2 #TabbedPane.closeBackground = #faa TabbedPane.closeForeground = #f00 TabbedPane.closeHoverBackground = #a00