mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 23:08:42 +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] > 65
|
||||||
: hsla[hslIndex] < 35;
|
: 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 ------------------------------------------
|
//---- class HSLIncreaseDecrease ------------------------------------------
|
||||||
@@ -148,5 +163,10 @@ public class ColorFunctions
|
|||||||
public void apply( float[] hsla ) {
|
public void apply( float[] hsla ) {
|
||||||
hsla[3] = clamp( amount );
|
hsla[3] = clamp( amount );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format( "fade(%.0f%%)", amount );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,4 +59,17 @@ public class DerivedColor
|
|||||||
public ColorFunction[] getFunctions() {
|
public ColorFunction[] getFunctions() {
|
||||||
return functions;
|
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.FlatLineBorder;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
import com.formdev.flatlaf.util.ColorFunctions.ColorFunction;
|
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.DerivedColor;
|
||||||
import com.formdev.flatlaf.util.StringUtils;
|
import com.formdev.flatlaf.util.StringUtils;
|
||||||
import com.formdev.flatlaf.util.SystemInfo;
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
@@ -409,7 +407,7 @@ public class UIDefaultsDump
|
|||||||
DerivedColor derivedColor = (DerivedColor) color;
|
DerivedColor derivedColor = (DerivedColor) color;
|
||||||
for( ColorFunction function : derivedColor.getFunctions() ) {
|
for( ColorFunction function : derivedColor.getFunctions() ) {
|
||||||
out.print( " " );
|
out.print( " " );
|
||||||
dumpColorFunction( out, function );
|
out.print( function.toString() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -421,27 +419,6 @@ public class UIDefaultsDump
|
|||||||
: String.format( "#%06x", color.getRGB() & 0xffffff );
|
: 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 ) {
|
private void dumpFont( PrintWriter out, Font font ) {
|
||||||
String strStyle = font.isBold()
|
String strStyle = font.isBold()
|
||||||
? font.isItalic() ? "bolditalic" : "bold"
|
? font.isItalic() ? "bolditalic" : "bold"
|
||||||
|
|||||||
Reference in New Issue
Block a user