|
|
|
@ -186,10 +186,10 @@ public class FineUIUtils {
|
|
|
|
|
* @param background 背景色 |
|
|
|
|
* @param width 宽度 |
|
|
|
|
* @param height 高度 |
|
|
|
|
* @param radius 圆角 |
|
|
|
|
* @param arc 圆角 |
|
|
|
|
*/ |
|
|
|
|
public static void paintWithComposite(Graphics g, Composite composite, Color background, |
|
|
|
|
int width, int height, int radius) { |
|
|
|
|
int width, int height, int arc) { |
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
|
|
|
|
|
|
FlatUIUtils.setRenderingHints(g2d); |
|
|
|
@ -197,7 +197,7 @@ public class FineUIUtils {
|
|
|
|
|
g2d.setComposite(composite); |
|
|
|
|
|
|
|
|
|
g2d.setColor(background); |
|
|
|
|
g2d.fill(new RoundRectangle2D.Float(0, 0, width, height, radius, radius)); |
|
|
|
|
g2d.fill(new RoundRectangle2D.Float(0, 0, width, height, arc, arc)); |
|
|
|
|
g2d.setComposite(oldComposite); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -247,14 +247,14 @@ public class FineUIUtils {
|
|
|
|
|
case LEFT: { |
|
|
|
|
path2D.append(createLeftRoundRectangle(x, y, width, height, arc), false); |
|
|
|
|
path2D.append(createLeftRoundRectangle(x + t, y + t, |
|
|
|
|
width - (closedPath ? t2x : t), height - t2x, arc - t), false); |
|
|
|
|
width - (closedPath ? t2x : t), height - t2x, arc - t2x), false); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
case RIGHT: |
|
|
|
|
default: { |
|
|
|
|
path2D.append(createRightRoundRectangle(x, y, width, height, arc), false); |
|
|
|
|
path2D.append(createRightRoundRectangle(x + (closedPath ? t : 0), y + t, |
|
|
|
|
width - (closedPath ? t2x : t), height - t2x, arc - t), false); |
|
|
|
|
width - (closedPath ? t2x : t), height - t2x, arc - t2x), false); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -280,12 +280,18 @@ public class FineUIUtils {
|
|
|
|
|
float t2x = t * 2; |
|
|
|
|
Path2D path2D = new Path2D.Float(Path2D.WIND_EVEN_ODD); |
|
|
|
|
path2D.append(createTopRoundRectangle(x, y, width, height, arc), false); |
|
|
|
|
path2D.append(createTopRoundRectangle(x + t, y + t, width - t2x, height - t, arc - t), false); |
|
|
|
|
path2D.append(createTopRoundRectangle(x + t, y + t, width - t2x, height - t, arc - t2x), false); |
|
|
|
|
g2.fill(path2D); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建一个部分圆角的矩形路径 |
|
|
|
|
* <p> |
|
|
|
|
* 注意: |
|
|
|
|
* 在swing中,UI的样式的 arc 数值是直径,而 css 中 border-radius 为半径, |
|
|
|
|
* 因此我们配置的 arc 全部为 border-radius 的2倍。但是使用 Path2D 绘制时, |
|
|
|
|
* 绘制方式其实是使用半径来进行计算的,为了保持调用一致,对外 API 还是以 arc |
|
|
|
|
* 的形式,因此方法内部需要对 arc 进行取半处理, |
|
|
|
|
* |
|
|
|
|
* @param x x坐标 |
|
|
|
|
* @param y y坐标 |
|
|
|
@ -299,16 +305,20 @@ public class FineUIUtils {
|
|
|
|
|
*/ |
|
|
|
|
public static Path2D createPartRoundRectangle(double x, double y, double width, double height, |
|
|
|
|
double arcTopLeft, double arcTopRight, double arcBottomRight, double arcBottomLeft) { |
|
|
|
|
Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD, 7); |
|
|
|
|
path.moveTo(x + arcTopLeft, y); |
|
|
|
|
path.lineTo(x + width - arcTopRight, y); |
|
|
|
|
path.quadTo(x + width, y, x + width, y + arcTopRight); |
|
|
|
|
path.lineTo(x + width, y + height - arcBottomRight); |
|
|
|
|
path.quadTo(x + width, y + height, x + width - arcBottomRight, y + height); |
|
|
|
|
path.lineTo(x + arcBottomLeft, y + height); |
|
|
|
|
path.quadTo(x, y + height, x, y + height - arcBottomLeft); |
|
|
|
|
path.lineTo(x, y + arcTopLeft); |
|
|
|
|
path.quadTo(x, y, x + arcTopLeft, y); |
|
|
|
|
double radiusTopLeft = arcTopLeft / 2; |
|
|
|
|
double radiusTopRight = arcTopRight / 2; |
|
|
|
|
double radiusBottomLeft = arcBottomLeft / 2; |
|
|
|
|
double radiusBottomRight = arcBottomRight / 2; |
|
|
|
|
Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD, 10); |
|
|
|
|
path.moveTo(x + radiusTopLeft, y); |
|
|
|
|
path.lineTo(x + width - radiusTopRight, y); |
|
|
|
|
path.quadTo(x + width, y, x + width, y + radiusTopRight); |
|
|
|
|
path.lineTo(x + width, y + height - radiusBottomRight); |
|
|
|
|
path.quadTo(x + width, y + height, x + width - radiusBottomRight, y + height); |
|
|
|
|
path.lineTo(x + radiusBottomLeft, y + height); |
|
|
|
|
path.quadTo(x, y + height, x, y + height - radiusBottomLeft); |
|
|
|
|
path.lineTo(x, y + radiusTopLeft); |
|
|
|
|
path.quadTo(x, y, x + radiusTopLeft, y); |
|
|
|
|
path.closePath(); |
|
|
|
|
return path; |
|
|
|
|
} |
|
|
|
|