From 4386c9d81773b0a4bf46c930fc6d40d1854fa379 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 12 Sep 2024 18:57:50 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-134499=20=E6=A0=B9=E6=8D=AEUI?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=9C=86=E8=A7=92=E5=B0=BA=E5=AF=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fine/theme/light/ui/FineButtonBorder.java | 2 +- .../theme/light/ui/FinePopupMenuBorder.java | 2 +- .../fine/theme/light/ui/FinePopupMenuUI.java | 2 +- .../light/ui/FineReportComponentBorder.java | 2 +- .../ui/FineReportComponentCompositeUI.java | 2 +- .../theme/light/ui/FineToggleButtonUI.java | 12 ++--- .../com/fine/theme/utils/FineUIUtils.java | 42 +++++++++------ .../gui/ibutton/UICombinationButton.java | 7 --- .../fr/design/mainframe/JFormSliderPane.java | 15 +++--- .../fr/startup/ui/StartupPageConstants.java | 16 +----- .../com/fr/startup/ui/StartupPageWindow.java | 3 +- .../light/ui/laf/FineLightLaf.properties | 10 ++-- .../fr/design/mainframe/SheetNameTabPane.java | 52 ++++++++++--------- 13 files changed, 81 insertions(+), 86 deletions(-) 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 fdf9b4cbe2..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 @@ -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); } /** * 创建一个部分圆角的矩形路径 + *

+ * 注意: + * 在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; } diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java index 70f229d2a3..ad9151fdbc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UICombinationButton.java +++ b/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); - } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java b/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java index cef7222edf..68fe5b3011 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java +++ b/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); } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java index 2dab229850..20d5f85ca6 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageConstants.java +++ b/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); } diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java index 45c955b12b..3100c064ae 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java +++ b/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()); diff --git a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties b/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties index aafdbdf666..c58cfad65c 100644 --- a/designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties +++ b/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 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java index 304639ec5c..4ab7827d44 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java +++ b/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(); From c2c49fb7835b0c8800b47d3e0e05835d934fb23b Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 12 Sep 2024 19:29:42 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/mainframe/JFormSliderPane.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java b/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java index 68fe5b3011..ce399c954d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java @@ -293,7 +293,11 @@ public class JFormSliderPane extends JPanel { showValFieldChange(value); } - + /** + * 添加值变化监听器 + * + * @param changeListener 变化监听器 + */ public void addValueChangeListener(ChangeListener changeListener) { this.slider.addChangeListener(changeListener); } From 1fec193a8dad1954e2c4ae33ac4f92a6296efcf6 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 12 Sep 2024 20:46:39 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DGridRow=E4=B8=AD=E5=AD=97=E7=AC=A6=E5=81=8F=E4=B8=8A?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/grid/GridRowUI.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridRowUI.java b/designer-realize/src/main/java/com/fr/grid/GridRowUI.java index d2b7391f84..e979aa9950 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridRowUI.java +++ b/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,15 +32,14 @@ import java.awt.geom.Rectangle2D; * @since 2012-3-22下午5:54:21 */ public class GridRowUI extends ComponentUI { - private Color detailsBackground = UIManager.getColor("Center.GridColumnRowColor"); 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){ - resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); + GridRowUI(int resolution) { + if (resolution == 0) { + resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); } this.resolution = resolution; } @@ -49,12 +49,12 @@ 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 Dimension size = gridRow.getSize(); - float time = (float)resolution/DesignerUIModeConfig.getInstance().getScreenResolution(); + float time = (float) resolution / DesignerUIModeConfig.getInstance().getScreenResolution(); g2d.setFont(gridRow.getFont().deriveFont(gridRow.getFont().getSize2D() * time)); ElementCase elementCase = reportPane.getEditingElementCase(); @@ -135,7 +135,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 +154,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; + float time = (float) resolution / DesignerUIModeConfig.getInstance().getScreenResolution(); + 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 + 2) { if (isSelectedBounds) { g2d.setColor(gridRow.getSelectedForeground()); } else { @@ -175,8 +178,10 @@ 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); } } -} \ No newline at end of file +} From b42207570a581c8f082e06042a9f633f4d0a004c Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 12 Sep 2024 20:48:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer-realize/src/main/java/com/fr/grid/GridRowUI.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/grid/GridRowUI.java b/designer-realize/src/main/java/com/fr/grid/GridRowUI.java index e979aa9950..5a7f0bf420 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridRowUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridRowUI.java @@ -32,6 +32,7 @@ import java.awt.geom.Rectangle2D; * @since 2012-3-22下午5:54:21 */ public class GridRowUI extends ComponentUI { + private static final int OFFSET = 2; protected Color editedBackground = UIManager.getColor("Center.GridColumnRowEditedColor"); protected Color selectedBackground = UIManager.getColor("Center.GridColumnRowSelectedColor"); @@ -166,7 +167,7 @@ public class GridRowUI extends ComponentUI { Rectangle2D bounds = new TextLayout(paintText, gridRow.getFont(), fontRenderContext).getBounds(); double stringHeight = bounds.getHeight() * time; // 如果高度太小了就不画了 - if (stringHeight <= increaseHeight + 2) { + if (stringHeight <= increaseHeight + OFFSET) { if (isSelectedBounds) { g2d.setColor(gridRow.getSelectedForeground()); } else {