diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineButtonBorder.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineButtonBorder.java
index 16405a1552..26ef4ec2ba 100644
--- a/designer-base/src/main/java/com/fine/theme/light/ui/FineButtonBorder.java
+++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineButtonBorder.java
@@ -32,7 +32,7 @@ public class FineButtonBorder extends FlatButtonBorder {
return;
}
g2.setPaint(borderPaint);
- FineUIUtils.paintPartRoundButtonBorder(c, g2, x, y, width, height, borderWidth, (float) getArc(c));
+ FineUIUtils.paintPartRoundButtonBorder(c, g2, x, y, width, height, borderWidth, getArc(c));
} else {
super.paintBorder(c, g, x, y, width, height);
}
diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuBorder.java b/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuBorder.java
index 63bf5e88e0..c7b827862f 100644
--- a/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuBorder.java
+++ b/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuBorder.java
@@ -14,6 +14,6 @@ public class FinePopupMenuBorder extends FlatPopupMenuBorder {
@Override
public int getArc() {
- return FineUIUtils.getAndScaleInt("PopupMenu.arc", 5);
+ return FineUIUtils.getAndScaleInt("PopupMenu.arc", 8);
}
}
diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java
index 58a37da791..e0cf691950 100644
--- a/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java
+++ b/designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java
@@ -19,7 +19,7 @@ import java.awt.geom.RoundRectangle2D;
*/
public class FinePopupMenuUI extends FlatPopupMenuUI {
private int arc;
- private final int DEFAULT_ARC = 10;
+ private final int DEFAULT_ARC = 8;
/**
* 创建UI
diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentBorder.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentBorder.java
index 6d381761ac..7ae570cb75 100644
--- a/designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentBorder.java
+++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentBorder.java
@@ -18,7 +18,7 @@ public class FineReportComponentBorder extends FlatRoundBorder {
@Override
protected int getArc(Component c) {
- return FineUIUtils.getAndScaleInt("Center.arc", 10);
+ return FineUIUtils.getAndScaleInt("Center.arc", 8);
}
@Override
diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentCompositeUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentCompositeUI.java
index 7886af3c33..8353f3e241 100644
--- a/designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentCompositeUI.java
+++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentCompositeUI.java
@@ -33,7 +33,7 @@ public class FineReportComponentCompositeUI extends FlatPanelUI {
@Override
protected void installDefaults(JPanel p) {
super.installDefaults(p);
- this.arc = FineUIUtils.getAndScaleInt("Center.arc", 10);
+ this.arc = FineUIUtils.getAndScaleInt("Center.arc", 8);
}
diff --git a/designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java b/designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java
index 49df9d63d1..8f14cd050c 100644
--- a/designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java
+++ b/designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java
@@ -111,7 +111,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
@Override
public void paint(Graphics g, JComponent c) {
if (isGroupButtonNotFit(c) || isTabButton(c)) {
- ((AbstractButton)c).setMargin(FineUIUtils.getUIInsets("ToggleButton.compact.margin", "ToggleButton.margin"));
+ ((AbstractButton) c).setMargin(FineUIUtils.getUIInsets("ToggleButton.compact.margin", "ToggleButton.margin"));
}
super.paint(g, c);
}
@@ -134,7 +134,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
// paint background
Color background;
- if(c.isEnabled() && selected) {
+ if (c.isEnabled() && selected) {
background = tabSelectedBackground;
} else {
Color enabledColor = selected ? clientPropertyColor(c, TAB_BUTTON_SELECTED_BACKGROUND, tabSelectedBackground) : null;
@@ -170,9 +170,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
float focusWidth = FlatUIUtils.getBorderFocusWidth(c);
FlatUIUtils.paintComponentBackground(g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0);
} else {
- float arc = FlatUIUtils.getBorderArc( c ) / 2;
- Shape path2D = getGroupButtonPath2D(c, position, arc);
- g2.fill(path2D);
+ g2.fill(getGroupButtonPath2D(c, position, FlatUIUtils.getBorderArc(c)));
}
} finally {
g2.dispose();
@@ -209,7 +207,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
@Override
protected Color getForeground(JComponent c) {
- if (isGroupButton(c) && ((AbstractButton)c).isSelected()) {
+ if (isGroupButton(c) && ((AbstractButton) c).isSelected()) {
return groupSelectedForeground;
}
return super.getForeground(c);
@@ -218,7 +216,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
@Override
protected Color getBackground(JComponent c) {
if (isGroupButton(c)) {
- return ((AbstractButton)c).isSelected() ? groupSelectedBackground : groupBackground;
+ return ((AbstractButton) c).isSelected() ? groupSelectedBackground : groupBackground;
}
return super.getBackground(c);
}
diff --git a/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java b/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
index c749bf5f3c..6ccf630ed2 100644
--- a/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
+++ b/designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
@@ -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;
/**
@@ -183,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);
@@ -194,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);
}
@@ -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)) {
- 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(createRightRoundRectangle(x, y, width, height, arc), false);
- path2D.append(createRightRoundRectangle(x, y + t, width - t, height - t2x, arc - t), false);
+ switch (roundPart) {
+
+ 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 - 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 - t2x), false);
+ break;
+ }
}
g2.fill(path2D);
}
@@ -246,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);
}
/**
* 创建一个部分圆角的矩形路径
+ *
+ * 注意:
+ * 在swing中,UI的样式的 arc 数值是直径,而 css 中 border-radius 为半径,
+ * 因此我们配置的 arc 全部为 border-radius 的2倍。但是使用 Path2D 绘制时,
+ * 绘制方式其实是使用半径来进行计算的,为了保持调用一致,对外 API 还是以 arc
+ * 的形式,因此方法内部需要对 arc 进行取半处理,
*
* @param x x坐标
* @param y y坐标
@@ -265,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;
}
@@ -452,6 +496,7 @@ public class FineUIUtils {
/**
* 创建一个支持自动换行的提示文本
+ *
* @param text 显示的文本内容
* @return 自动换行提示文本
*/
diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
index 387c01bb9b..89b0b9fac0 100644
--- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
+++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
@@ -104,12 +104,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
* The manager of Designer GUI.
* 下面的作者日期都是随手写的,具体作者已经无法考究。
*
- * @author anonymous
- * @version 11.0
+ * @author anonymous
+ * @version 11.0
* created by anonymous on 2002/11/08
*/
public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReadable {
-
+
private static final int MAX_SHOW_NUM = 10;
private static final String VERSION_80 = "80";
private static final String VERSION_90 = "90";
@@ -122,26 +122,26 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada
* 指定默认工作空间
*/
public static final String DEFAULT_WORKSPACE_PATH = "fr.designer.workspace.default";
-
+
public static final String LAST_EAST_REGION_LAYOUT = "LastEastRegionLayout";
public static final String LAST_WEST_REGION_LAYOUT = "LastWestRegionLayout";
-
+
private static DesignerEnvManager designerEnvManager; // gui.
private String activationKey = null;
private String logLocation = null;
private Rectangle windowBounds = null; // window bounds.
private String DialogCurrentDirectory = null;
private String CurrentDirectoryPrefix = null;
-
+
private Map> recentOpenedFileListMap = new HashMap<>();
private List tempRecentOpenedFilePathList = new ArrayList();
private XmlElement