@ -44,6 +44,9 @@ import static com.formdev.flatlaf.util.UIScale.scale;
* /
public class FineUIUtils {
public static final String LEFT = "LEFT" ;
public static final String RIGHT = "RIGHT" ;
public static final int RETINA_SCALE_FACTOR = 2 ;
/ * *
@ -212,17 +215,48 @@ public class FineUIUtils {
* /
public static void paintPartRoundButtonBorder ( Component c , Graphics2D g2 , int x , int y , int width , int height ,
float borderWidth , float arc ) {
if ( isLeftRoundButton ( c ) ) {
paintPartRoundButtonBorder ( g2 , x , y , width , height , borderWidth , arc , LEFT , false ) ;
} else {
paintPartRoundButtonBorder ( g2 , x , y , width , height , borderWidth , arc , RIGHT , false ) ;
}
}
/ * *
* 绘制部分圆角矩形边框
*
* @param g2 Graphics2D
* @param x x坐标
* @param y y坐标
* @param width 宽度
* @param height 高度
* @param borderWidth 边框宽度
* @param arc 圆角
* @param roundPart 圆角的方位 , 当前只能设置一侧
* @param closedPath 是否封闭 , 非圆角那一侧是否有边框 , 是为有边框
* /
public static void paintPartRoundButtonBorder ( Graphics2D g2 , int x , int y , int width , int height ,
float borderWidth , float arc , String roundPart , boolean closedPath ) {
FlatUIUtils . setRenderingHints ( g2 ) ;
arc = scale ( arc ) ;
float t = scale ( borderWidth ) ;
float t2x = t * 2 ;
Path2D path2D = new Path2D . Float ( Path2D . WIND_EVEN_ODD ) ;
if ( isLeftRoundButton ( c ) ) {
switch ( roundPart ) {
case LEFT : {
path2D . append ( createLeftRoundRectangle ( x , y , width , height , arc ) , false ) ;
path2D . append ( createLeftRoundRectangle ( x + t , y + t , width - t , height - t2x , arc - t ) , false ) ;
} else {
path2D . append ( createLeftRoundRectangle ( x + t , y + t ,
width - ( closedPath ? t2x : t ) , height - t2x , arc - t ) , false ) ;
break ;
}
case RIGHT :
default : {
path2D . append ( createRightRoundRectangle ( x , y , width , height , arc ) , false ) ;
path2D . append ( createRightRoundRectangle ( x , y + t , width - t , height - t2x , arc - t ) , false ) ;
path2D . append ( createRightRoundRectangle ( x + ( closedPath ? t : 0 ) , y + t ,
width - ( closedPath ? t2x : t ) , height - t2x , arc - t ) , false ) ;
break ;
}
}
g2 . fill ( path2D ) ;
}
@ -452,6 +486,7 @@ public class FineUIUtils {
/ * *
* 创建一个支持自动换行的提示文本
*
* @param text 显示的文本内容
* @return 自动换行提示文本
* /