mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 06:50:56 +03:00
UI defaults inspector: show color functions in value tooltips
This commit is contained in:
@@ -128,6 +128,21 @@ public class ColorFunctions
|
||||
? hsla[hslIndex] > 65
|
||||
: hsla[hslIndex] < 35;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String name;
|
||||
switch( hslIndex ) {
|
||||
case 0: name = "spin"; break;
|
||||
case 1: name = increase ? "saturate" : "desaturate"; break;
|
||||
case 2: name = increase ? "lighten" : "darken"; break;
|
||||
case 3: name = increase ? "fadein" : "fadeout"; break;
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
return String.format( "%s(%.0f%%%s%s)", name, amount,
|
||||
(relative ? " relative" : ""),
|
||||
(autoInverse ? " autoInverse" : "") );
|
||||
}
|
||||
}
|
||||
|
||||
//---- class HSLIncreaseDecrease ------------------------------------------
|
||||
@@ -148,5 +163,10 @@ public class ColorFunctions
|
||||
public void apply( float[] hsla ) {
|
||||
hsla[3] = clamp( amount );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format( "fade(%.0f%%)", amount );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,17 @@ public class DerivedColor
|
||||
public ColorFunction[] getFunctions() {
|
||||
return functions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append( super.toString() );
|
||||
|
||||
for( ColorFunction function : functions ) {
|
||||
buf.append( '\n' );
|
||||
buf.append( function.toString() );
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,6 @@ import com.formdev.flatlaf.testing.FlatTestLaf;
|
||||
import com.formdev.flatlaf.ui.FlatLineBorder;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.ColorFunctions.ColorFunction;
|
||||
import com.formdev.flatlaf.util.ColorFunctions.Fade;
|
||||
import com.formdev.flatlaf.util.ColorFunctions.HSLIncreaseDecrease;
|
||||
import com.formdev.flatlaf.util.DerivedColor;
|
||||
import com.formdev.flatlaf.util.StringUtils;
|
||||
import com.formdev.flatlaf.util.SystemInfo;
|
||||
@@ -409,7 +407,7 @@ public class UIDefaultsDump
|
||||
DerivedColor derivedColor = (DerivedColor) color;
|
||||
for( ColorFunction function : derivedColor.getFunctions() ) {
|
||||
out.print( " " );
|
||||
dumpColorFunction( out, function );
|
||||
out.print( function.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -421,27 +419,6 @@ public class UIDefaultsDump
|
||||
: String.format( "#%06x", color.getRGB() & 0xffffff );
|
||||
}
|
||||
|
||||
private void dumpColorFunction( PrintWriter out, ColorFunction function ) {
|
||||
if( function instanceof HSLIncreaseDecrease ) {
|
||||
HSLIncreaseDecrease func = (HSLIncreaseDecrease) function;
|
||||
String name;
|
||||
switch( func.hslIndex ) {
|
||||
case 0: name = "spin"; break;
|
||||
case 1: name = func.increase ? "saturate" : "desaturate"; break;
|
||||
case 2: name = func.increase ? "lighten" : "darken"; break;
|
||||
case 3: name = func.increase ? "fadein" : "fadeout"; break;
|
||||
default: throw new IllegalArgumentException();
|
||||
}
|
||||
out.printf( "%s(%.0f%%%s%s)", name, func.amount,
|
||||
(func.relative ? " relative" : ""),
|
||||
(func.autoInverse ? " autoInverse" : "") );
|
||||
} else if( function instanceof Fade ) {
|
||||
Fade func = (Fade) function;
|
||||
out.printf( "fade(%.0f%%)", func.amount );
|
||||
} else
|
||||
throw new IllegalArgumentException( "unknown color function: " + function );
|
||||
}
|
||||
|
||||
private void dumpFont( PrintWriter out, Font font ) {
|
||||
String strStyle = font.isBold()
|
||||
? font.isItalic() ? "bolditalic" : "bold"
|
||||
|
||||
Reference in New Issue
Block a user