mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
FlatLineBorder: support specifying painted line thickness
This commit is contained in:
@@ -332,16 +332,17 @@ class UIDefaultsLoader
|
||||
|
||||
private static Object parseBorder( String value, Function<String, String> resolver, List<ClassLoader> addonClassLoaders ) {
|
||||
if( value.indexOf( ',' ) >= 0 ) {
|
||||
// top,left,bottom,right[,lineColor]
|
||||
// top,left,bottom,right[,lineColor[,lineThickness]]
|
||||
List<String> parts = split( value, ',' );
|
||||
Insets insets = parseInsets( value );
|
||||
ColorUIResource lineColor = (parts.size() == 5)
|
||||
ColorUIResource lineColor = (parts.size() >= 5)
|
||||
? (ColorUIResource) parseColorOrFunction( resolver.apply( parts.get( 4 ) ), resolver, true )
|
||||
: null;
|
||||
float lineThickness = (parts.size() >= 6) ? parseFloat( parts.get( 5 ), true ) : 1f;
|
||||
|
||||
return (LazyValue) t -> {
|
||||
return (lineColor != null)
|
||||
? new FlatLineBorder( insets, lineColor )
|
||||
? new FlatLineBorder( insets, lineColor, lineThickness )
|
||||
: new FlatEmptyBorder( insets );
|
||||
};
|
||||
} else
|
||||
|
||||
@@ -26,9 +26,9 @@ import java.awt.Insets;
|
||||
/**
|
||||
* Line border for various components.
|
||||
*
|
||||
* Paints a scaled 1px thick line around the component.
|
||||
* The line thickness is not included in the border insets.
|
||||
* The insets should be at least 1,1,1,1.
|
||||
* Paints a scaled (usually 1px thick) line around the component.
|
||||
* The line thickness is not added to the border insets.
|
||||
* The insets should be at least have line thickness (usually 1,1,1,1).
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
@@ -36,10 +36,16 @@ public class FlatLineBorder
|
||||
extends FlatEmptyBorder
|
||||
{
|
||||
private final Color lineColor;
|
||||
private final float lineThickness;
|
||||
|
||||
public FlatLineBorder( Insets insets, Color lineColor ) {
|
||||
this( insets, lineColor, 1f );
|
||||
}
|
||||
|
||||
public FlatLineBorder( Insets insets, Color lineColor, float lineThickness ) {
|
||||
super( insets );
|
||||
this.lineColor = lineColor;
|
||||
this.lineThickness = lineThickness;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +54,7 @@ public class FlatLineBorder
|
||||
try {
|
||||
FlatUIUtils.setRenderingHints( g2 );
|
||||
g2.setColor( lineColor );
|
||||
FlatUIUtils.paintComponentBorder( g2, x, y, width, height, 0f, scale( 1f ), 0f );
|
||||
FlatUIUtils.paintComponentBorder( g2, x, y, width, height, 0f, scale( lineThickness ), 0f );
|
||||
} finally {
|
||||
g2.dispose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user