Browse Source

Pull request #14815: REPORT-134499 根据UI统一圆角尺寸

Merge in DESIGN/design from ~VITO/c-design:fbp/release to fbp/release

* commit 'b42207570a581c8f082e06042a9f633f4d0a004c':
  无jira任务 代码质量
  无jira任务 修复GridRow中字符偏上的问题
  无jira任务 代码质量
  REPORT-134499 根据UI统一圆角尺寸
fbp/release
vito-刘恒霖 2 months ago
parent
commit
37547873c4
  1. 2
      designer-base/src/main/java/com/fine/theme/light/ui/FineButtonBorder.java
  2. 2
      designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuBorder.java
  3. 2
      designer-base/src/main/java/com/fine/theme/light/ui/FinePopupMenuUI.java
  4. 2
      designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentBorder.java
  5. 2
      designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentCompositeUI.java
  6. 4
      designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java
  7. 42
      designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
  8. 7
      designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java
  9. 13
      designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java
  10. 16
      designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java
  11. 3
      designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java
  12. 10
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  13. 10
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java
  14. 26
      designer-realize/src/main/java/com/fr/grid/GridRowUI.java

2
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);
}

2
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);
}
}

2
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

2
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

2
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);
}

4
designer-base/src/main/java/com/fine/theme/light/ui/FineToggleButtonUI.java

@ -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();

42
designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java

@ -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;
}

7
designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java

@ -1,10 +1,7 @@
package com.fr.design.gui.ibutton;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -148,8 +145,4 @@ public class UICombinationButton extends JPanel {
rightButton.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON);
setStyle(rightButton, IN_TOOLBAR_RIGHT);
}
protected void showPopWindow(JPopupMenu menu) {
GUICoreUtils.showPopupMenu(menu, this, 0, getY() + getHeight() - 3);
}
}

13
designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java

@ -164,7 +164,6 @@ public class JFormSliderPane extends JPanel {
}
private void showValFieldChange(int value) {
isButtonOrIsTxt = true;
showValue = getPreferredValue(value);
@ -230,8 +229,10 @@ public class JFormSliderPane extends JPanel {
@Override
public void paintComponent(Graphics g) {
int arc = FineUIUtils.getAndScaleInt("Center.arc", 10) / 2;
Path2D roundedPath = FineUIUtils.createPartRoundRectangle(0, 0, this.getWidth(), this.getHeight(), 0, 0, arc, 0);
int arc = FineUIUtils.getAndScaleInt("Center.arc", 8);
Path2D roundedPath = FineUIUtils.createPartRoundRectangle(0, 0,
this.getWidth(), this.getHeight(),
0, 0, arc, 0);
FlatUIUtils.setRenderingHints(g);
Graphics2D g2 = (Graphics2D) g;
g2.setColor(getBackground());
@ -292,7 +293,11 @@ public class JFormSliderPane extends JPanel {
showValFieldChange(value);
}
/**
* 添加值变化监听器
*
* @param changeListener 变化监听器
*/
public void addValueChangeListener(ChangeListener changeListener) {
this.slider.addChangeListener(changeListener);
}

16
designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java

@ -1,29 +1,17 @@
package com.fr.startup.ui;
import java.awt.Color;
/**
* created by Harrison on 2022/07/07
**/
public class StartupPageConstants {
/**
* 弧长度
* 角直径
*/
public static final int ARC_DIAMETER = 10;
public static final int ARC_DIAMETER = 16;
/**
* 内容宽度
*/
public static final int CONTENT_WIDTH = 850;
/**
* 边框的颜色
*/
public static final Color BORDER_COLOR = Color.WHITE;
/**
* 透明的颜色
*/
public static final Color TRANSPARENT_COLOR = new Color(0, 0, 0, 0);
}

3
designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java

@ -292,7 +292,8 @@ public class StartupPageWindow extends JFrame {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(color);
g2d.fillRoundRect(0, 0, getWidth(), getHeight(), 2 * StartupPageConstants.ARC_DIAMETER, 2 * StartupPageConstants.ARC_DIAMETER);
g2d.fillRoundRect(0, 0, getWidth(), getHeight(),
StartupPageConstants.ARC_DIAMETER, StartupPageConstants.ARC_DIAMETER);
}
};
recentOpenPanel.setLayout(new BorderLayout());

10
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

@ -230,7 +230,7 @@ CombinationButton.arc = $Button.arc
#---- CheckBox ----
CheckBox.arc = 4
CheckBox.arc = $Component.arc
CheckBox.margin = 2,0,2,0
CheckBox.iconTextGap = 4
CheckBox.rollover = true
@ -330,7 +330,7 @@ Component.focusWidth = 0
Component.innerFocusWidth = 0.5
Component.innerOutlineWidth = 1
Component.borderWidth = 1
Component.arc = 5
Component.arc = 6
Component.minimumWidth = 64
# allowed values: chevron or triangle
Component.arrowType = chevron
@ -580,7 +580,7 @@ PopupMenu.background=$background.normal
PopupMenu.scrollArrowColor = @buttonArrowColor
PopupMenu.borderColor=$border.divider
PopupMenu.hoverScrollArrowBackground = darken(@background,5%)
PopupMenu.arc=10
PopupMenu.arc=8
#---- PopupMenuSeparator ----
PopupMenuSeparator.height=5
@ -887,7 +887,7 @@ TemplateTabPane.borderColor = $border.divider
TemplateTabPane.closeHoverBackground = $hover.deep
TemplateTabPane.tabInsets = 4,6,4,6
TemplateTabPane.borderWidth = 1
TemplateTabPane.tabArc = 5
TemplateTabPane.tabArc = 8
TemplateTabPane.separatorHeight = 14
TemplateTabPane.icon.hoverBackground = #B8BFCB
@ -1206,7 +1206,7 @@ Center.GridColumnRowEditedColor=#e9ecf1
Center.GridCornerFill=fade(#0A1C38, 47%)
Center.SpaceColor = #FFF
Center.border = 0, 10, 10, 10
Center.arc=10
Center.arc=8
#---- CellOtherSetPane ----
CellOtherSetPane.height=$Component.defaultHeight

10
designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java

@ -202,7 +202,8 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
}
});
listener = new ComponentAdapter() {
@Override public void componentResized(ComponentEvent e) {
@Override
public void componentResized(ComponentEvent e) {
for (int i = 0; i < lastOneIndex * NUM; i++) {
moveLeft();
}
@ -328,6 +329,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
/**
* 抽出来方便OEM
*
* @return
*/
public Icon getAddWorkSheet() {
@ -368,8 +370,10 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
private void paintBackgroundAndLine(Graphics2D g2d, double textHeight, double maxWidth, int charWidth, int textAscent) {
int arc = FineUIUtils.getAndScaleInt("Center.arc", 10) / 2;
Path2D roundedPath = FineUIUtils.createPartRoundRectangle(0, 0, this.getWidth(), this.getHeight(), 0, 0, 0, arc);
int arc = FineUIUtils.getAndScaleInt("Center.arc", 8);
Path2D roundedPath = FineUIUtils.createPartRoundRectangle(0, 0,
this.getWidth(), this.getHeight(),
0, 0, 0, arc);
FlatUIUtils.setRenderingHints(g2d);
g2d.setColor(getBackground());
g2d.fill(roundedPath);

26
designer-realize/src/main/java/com/fr/grid/GridRowUI.java

@ -24,6 +24,7 @@ import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.Rectangle2D;
/**
@ -31,11 +32,11 @@ import java.awt.geom.Rectangle2D;
* @since 2012-3-22下午5:54:21
*/
public class GridRowUI extends ComponentUI {
private Color detailsBackground = UIManager.getColor("Center.GridColumnRowColor");
private static final int OFFSET = 2;
protected Color editedBackground = UIManager.getColor("Center.GridColumnRowEditedColor");
protected Color selectedBackground = UIManager.getColor("Center.GridColumnRowSelectedColor");
private int resolution ;
private final int resolution;
GridRowUI(int resolution) {
if (resolution == 0) {
@ -49,7 +50,7 @@ public class GridRowUI extends ComponentUI {
if (!(c instanceof GridRow)) {
throw new IllegalArgumentException("The component c to paint must be a GridColumn!");
}
Graphics2D g2d = (Graphics2D) g;
Graphics2D g2d = (Graphics2D) g.create();
GridRow gridRow = (GridRow) c;
ElementCasePane reportPane = gridRow.getElementCasePane();
// size
@ -135,7 +136,7 @@ public class GridRowUI extends ComponentUI {
paintText += "(F)";
}
}
drawNormalContent(i, g2d, gridRow, paintText, tmpIncreaseHeight, isSelectedBounds, elementCase, size, tmpHeight1);
drawNormalContent(g2d, gridRow, paintText, tmpIncreaseHeight, isSelectedBounds, size, tmpHeight1);
}
}
@ -154,16 +155,19 @@ public class GridRowUI extends ComponentUI {
}
private void drawNormalContent(int i, Graphics2D g2d, GridRow gridRow, String paintText, double tmpIncreaseHeight, boolean isSelectedBounds
, ElementCase elementCase, Dimension size, double tmpHeight1) {
private void drawNormalContent(Graphics2D g2d, GridRow gridRow, String paintText,
double increaseHeight, boolean isSelectedBounds,
Dimension size, double y) {
// FontMetrics
FontRenderContext fontRenderContext = g2d.getFontRenderContext();
float time = (float) resolution / DesignerUIModeConfig.getInstance().getScreenResolution();
float fmAscent = GraphHelper.getFontMetrics(gridRow.getFont()).getAscent() * time;
double stringWidth = gridRow.getFont().getStringBounds(paintText, fontRenderContext).getWidth() * time;
double stringHeight = gridRow.getFont().getStringBounds(paintText, fontRenderContext).getHeight() * time;
// 为了居中获取可视边界
Rectangle2D bounds = new TextLayout(paintText, gridRow.getFont(), fontRenderContext).getBounds();
double stringHeight = bounds.getHeight() * time;
// 如果高度太小了就不画了
if (stringHeight <= tmpIncreaseHeight + 2) {
if (stringHeight <= increaseHeight + OFFSET) {
if (isSelectedBounds) {
g2d.setColor(gridRow.getSelectedForeground());
} else {
@ -175,7 +179,9 @@ public class GridRowUI extends ComponentUI {
}
}
GraphHelper.drawString(g2d, paintText, (size.width - stringWidth) / 2, tmpHeight1 + (tmpIncreaseHeight - stringHeight) / 2 + GridHeader.SIZE_ADJUST / 2 + fmAscent - 2);
GraphHelper.drawString(g2d, paintText,
(size.width - stringWidth) / 2,
y + (increaseHeight - stringHeight) / 2.0 + stringHeight);
}
}

Loading…
Cancel
Save