mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 23:37:13 -06:00
UI defaults inspector:
- no longer show color values as decimal rgb - use black for color value text if color is translucent - fix derived color tooltip - improved filter performance
This commit is contained in:
@@ -410,9 +410,11 @@ public class FlatUIDefaultsInspector
|
|||||||
String valueType = (String) valueTypeField.getSelectedItem();
|
String valueType = (String) valueTypeField.getSelectedItem();
|
||||||
|
|
||||||
// split filter string on space characters
|
// split filter string on space characters
|
||||||
String[] filters = filter.split( " +" );
|
String[] filters = !filter.isEmpty() ? filter.split( " +" ) : null;
|
||||||
for( int i = 0; i < filters.length; i++ )
|
if( filters != null ) {
|
||||||
filters[i] = filters[i].toLowerCase( Locale.ENGLISH );
|
for( int i = 0; i < filters.length; i++ )
|
||||||
|
filters[i] = filters[i].toLowerCase( Locale.ENGLISH );
|
||||||
|
}
|
||||||
|
|
||||||
ItemsTableModel model = (ItemsTableModel) table.getModel();
|
ItemsTableModel model = (ItemsTableModel) table.getModel();
|
||||||
model.setFilter( item -> {
|
model.setFilter( item -> {
|
||||||
@@ -421,6 +423,9 @@ public class FlatUIDefaultsInspector
|
|||||||
!valueType.equals( typeOfValue( item.value ) ) )
|
!valueType.equals( typeOfValue( item.value ) ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if( filters == null )
|
||||||
|
return true;
|
||||||
|
|
||||||
String lkey = item.key.toLowerCase( Locale.ENGLISH );
|
String lkey = item.key.toLowerCase( Locale.ENGLISH );
|
||||||
String lvalue = item.getValueAsString().toLowerCase( Locale.ENGLISH );
|
String lvalue = item.getValueAsString().toLowerCase( Locale.ENGLISH );
|
||||||
for( String f : filters ) {
|
for( String f : filters ) {
|
||||||
@@ -652,15 +657,13 @@ public class FlatUIDefaultsInspector
|
|||||||
Color color = (value instanceof Color[]) ? ((Color[])value)[0] : (Color) value;
|
Color color = (value instanceof Color[]) ? ((Color[])value)[0] : (Color) value;
|
||||||
HSLColor hslColor = new HSLColor( color );
|
HSLColor hslColor = new HSLColor( color );
|
||||||
if( color.getAlpha() == 255 ) {
|
if( color.getAlpha() == 255 ) {
|
||||||
return String.format( "%s rgb(%d, %d, %d) hsl(%d, %d, %d)",
|
return String.format( "%-9s HSL %3d %3d %3d",
|
||||||
color2hex( color ),
|
color2hex( color ),
|
||||||
color.getRed(), color.getGreen(), color.getBlue(),
|
|
||||||
(int) hslColor.getHue(), (int) hslColor.getSaturation(),
|
(int) hslColor.getHue(), (int) hslColor.getSaturation(),
|
||||||
(int) hslColor.getLuminance() );
|
(int) hslColor.getLuminance() );
|
||||||
} else {
|
} else {
|
||||||
return String.format( "%s rgba(%d, %d, %d, %d) hsla(%d, %d, %d, %d)",
|
return String.format( "%-9s HSL %3d %3d %3d %2d",
|
||||||
color2hex( color ),
|
color2hex( color ),
|
||||||
color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha(),
|
|
||||||
(int) hslColor.getHue(), (int) hslColor.getSaturation(),
|
(int) hslColor.getHue(), (int) hslColor.getSaturation(),
|
||||||
(int) hslColor.getLuminance(), (int) (hslColor.getAlpha() * 100) );
|
(int) hslColor.getLuminance(), (int) (hslColor.getAlpha() * 100) );
|
||||||
}
|
}
|
||||||
@@ -970,7 +973,7 @@ public class FlatUIDefaultsInspector
|
|||||||
|
|
||||||
if( item.value instanceof Color || item.value instanceof Color[] ) {
|
if( item.value instanceof Color || item.value instanceof Color[] ) {
|
||||||
Color color = (item.value instanceof Color[]) ? ((Color[])item.value)[0] : (Color) item.value;
|
Color color = (item.value instanceof Color[]) ? ((Color[])item.value)[0] : (Color) item.value;
|
||||||
boolean isDark = new HSLColor( color ).getLuminance() < 70;
|
boolean isDark = new HSLColor( color ).getLuminance() < 70 && color.getAlpha() >= 128;
|
||||||
setBackground( color );
|
setBackground( color );
|
||||||
setForeground( isDark ? Color.white : Color.black );
|
setForeground( isDark ? Color.white : Color.black );
|
||||||
} else if( item.value instanceof Icon ) {
|
} else if( item.value instanceof Icon ) {
|
||||||
@@ -979,7 +982,9 @@ public class FlatUIDefaultsInspector
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set tooltip
|
// set tooltip
|
||||||
String toolTipText = String.valueOf( item.value );
|
String toolTipText = (item.value instanceof Object[])
|
||||||
|
? Arrays.toString( (Object[]) item.value ).replace( ", ", ",\n" )
|
||||||
|
: String.valueOf( item.value );
|
||||||
if( item.lafValue != null ) {
|
if( item.lafValue != null ) {
|
||||||
toolTipText += " \n\nLaF UI default value was overridden with UIManager.put(key,value):\n "
|
toolTipText += " \n\nLaF UI default value was overridden with UIManager.put(key,value):\n "
|
||||||
+ Item.valueAsString( item.lafValue ) + "\n " + String.valueOf( item.lafValue );
|
+ Item.valueAsString( item.lafValue ) + "\n " + String.valueOf( item.lafValue );
|
||||||
@@ -1027,18 +1032,14 @@ public class FlatUIDefaultsInspector
|
|||||||
|
|
||||||
g.setColor( getForeground() );
|
g.setColor( getForeground() );
|
||||||
|
|
||||||
// paint rgb() and hsl() horizontally aligned
|
// paint hsl horizontally aligned
|
||||||
int rgbIndex = text.indexOf( "rgb" );
|
int hslIndex = text.indexOf( "HSL" );
|
||||||
int hslIndex = text.indexOf( "hsl" );
|
if( hslIndex > 0 ) {
|
||||||
if( rgbIndex > 0 && hslIndex > rgbIndex ) {
|
String hexText = text.substring( 0, hslIndex );
|
||||||
String hexText = text.substring( 0, rgbIndex );
|
|
||||||
String rgbText = text.substring( rgbIndex, hslIndex );
|
|
||||||
String hslText = text.substring( hslIndex );
|
String hslText = text.substring( hslIndex );
|
||||||
int hexWidth = Math.max( fm.stringWidth( hexText ), fm.stringWidth( "#DDDDDD " ) );
|
int hexWidth = Math.max( fm.stringWidth( hexText ), fm.stringWidth( "#12345678 " ) );
|
||||||
int rgbWidth = Math.max( fm.stringWidth( rgbText ), fm.stringWidth( "rgb(444, 444, 444) " ) );
|
|
||||||
FlatUIUtils.drawString( this, g, hexText, x, y );
|
FlatUIUtils.drawString( this, g, hexText, x, y );
|
||||||
FlatUIUtils.drawString( this, g, rgbText, x + hexWidth, y );
|
FlatUIUtils.drawString( this, g, hslText, x + hexWidth, y );
|
||||||
FlatUIUtils.drawString( this, g, hslText, x + hexWidth + rgbWidth, y );
|
|
||||||
} else
|
} else
|
||||||
FlatUIUtils.drawString( this, g, text, x, y );
|
FlatUIUtils.drawString( this, g, text, x, y );
|
||||||
} else
|
} else
|
||||||
|
|||||||
Reference in New Issue
Block a user