Browse Source

REPORT-134499 根据UI统一圆角尺寸

fbp/release
vito 2 months ago
parent
commit
4386c9d817
  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. 12
      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. 15
      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. 52
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.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);
}

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

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

15
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);
@ -172,7 +171,7 @@ public class JFormSliderPane extends JPanel {
refreshSlider();
}
private int getPreferredValue(int value){
private int getPreferredValue(int value) {
if (value > FOUR_HUNDRED) {
value = FOUR_HUNDRED;
}
@ -182,7 +181,7 @@ public class JFormSliderPane extends JPanel {
return value;
}
private void refreshShowValueFieldText(){
private void refreshShowValueFieldText() {
showValField.setValue(showValue);
setAdjustButtonStatus();
}
@ -211,7 +210,7 @@ public class JFormSliderPane extends JPanel {
slider.setValue(calSliderValue(showValue));
}
private void setAdjustButtonStatus(){
private void setAdjustButtonStatus() {
this.downButton.setEnabled(this.showValue > TEN);
this.upButton.setEnabled(this.showValue < FOUR_HUNDRED);
}
@ -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());
@ -293,7 +294,7 @@ public class JFormSliderPane extends JPanel {
}
public void addValueChangeListener(ChangeListener 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

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

@ -201,8 +201,9 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
}
}
});
listener = new ComponentAdapter(){
@Override public void componentResized(ComponentEvent e) {
listener = new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
for (int i = 0; i < lastOneIndex * NUM; i++) {
moveLeft();
}
@ -277,7 +278,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
* @param oldIndex
*/
protected void doBeforeChange(int oldIndex) {
reportComposite.doBeforeChange(oldIndex);
reportComposite.doBeforeChange(oldIndex);
}
/**
@ -286,7 +287,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
* @param newIndex
*/
protected void doAfterChange(int newIndex) {
reportComposite.doAfterChange(newIndex);
reportComposite.doAfterChange(newIndex);
}
/**
@ -328,10 +329,11 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
/**
* 抽出来方便OEM
*
* @return
*/
public Icon getAddWorkSheet(){
return ADD_WORK_SHEET;
public Icon getAddWorkSheet() {
return ADD_WORK_SHEET;
}
/**
@ -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);
@ -415,8 +419,8 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
paintAddButton(g2d);
}
protected void paintAddButton(Graphics2D g2d){
getAddWorkSheet().paintIcon(this, g2d, iconLocation, 3);
protected void paintAddButton(Graphics2D g2d) {
getAddWorkSheet().paintIcon(this, g2d, iconLocation, 3);
ADD_POLY_SHEET.paintIcon(this, g2d, iconLocation + getAddWorkSheet().getIconWidth() + iconSepDistance, 3);
}
@ -559,41 +563,41 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
}
if (SwingUtilities.isLeftMouseButton(evt)) {
processLeftMouseButton(evtX);
processLeftMouseButton(evtX);
}
if (isBlank) {
return;
}
if (SwingUtilities.isRightMouseButton(evt) && !isAuthorityEditing) {
processRightMouseButton(evtX, evtY);
processRightMouseButton(evtX, evtY);
}
}
private void processRightMouseButton(int evtX, int evtY){
private void processRightMouseButton(int evtX, int evtY) {
MenuDef def = new MenuDef();
addInsertGridShortCut(def);
def.addShortCut(new PolyReportInsertAction(), SeparatorDef.DEFAULT, new RemoveSheetAction(), new RenameSheetAction(),
new CopySheetAction());
def.addShortCut(new PolyReportInsertAction(), SeparatorDef.DEFAULT, new RemoveSheetAction(), new RenameSheetAction(),
new CopySheetAction());
JPopupMenu tabPop = def.createJMenu().getPopupMenu();
def.updateMenu();
GUICoreUtils.showPopupMenu(tabPop, this, evtX - 1, evtY - 1);
}
private void processLeftMouseButton(int evtX){
private void processLeftMouseButton(int evtX) {
if (evtX > iconLocation && evtX < iconLocation + scale(GRID_TOSHEET_RIGHT)) {
firstInsertActionPerformed();
firstInsertActionPerformed();
} else if (evtX > iconLocation + scale(POLY_TOSHEET_LEFT) && evtX < iconLocation + scale(POLY_TOSHEET_RIGHT)) {
new PolyReportInsertAction().actionPerformed(null);
}
}
protected void addInsertGridShortCut(MenuDef def){
def.addShortCut(new GridReportInsertAction());
protected void addInsertGridShortCut(MenuDef def) {
def.addShortCut(new GridReportInsertAction());
}
protected void firstInsertActionPerformed(){
new GridReportInsertAction().actionPerformed(null);
protected void firstInsertActionPerformed() {
new GridReportInsertAction().actionPerformed(null);
}
@ -645,7 +649,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
* 右移动
*
* @param moveRighttDistance 右侧移动距离
* @param si 宽度坐标
* @param si 宽度坐标
*/
private void move2Right(int moveRighttDistance, int si) {
int reportcount = reportComposite.getEditingWorkBook().getReportCount();
@ -671,7 +675,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
* 左移动
*
* @param moveLeftDistance 左侧距离
* @param si 宽度坐标
* @param si 宽度坐标
*/
private void move2Left(int moveLeftDistance, int si) {
if (selectedIndex > 0) {
@ -746,7 +750,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
scrollIndex++;
}
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateTheme theme = template.getTemplateTheme();
TemplateReport templateReport = newTemplateReport();

Loading…
Cancel
Save