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-刘恒霖 3 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. 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. 21
      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. 26
      designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java
  14. 34
      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; return;
} }
g2.setPaint(borderPaint); 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 { } else {
super.paintBorder(c, g, x, y, width, height); 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 @Override
public int getArc() { 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 { public class FinePopupMenuUI extends FlatPopupMenuUI {
private int arc; private int arc;
private final int DEFAULT_ARC = 10; private final int DEFAULT_ARC = 8;
/** /**
* 创建UI * 创建UI

2
designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentBorder.java

@ -18,7 +18,7 @@ public class FineReportComponentBorder extends FlatRoundBorder {
@Override @Override
protected int getArc(Component c) { protected int getArc(Component c) {
return FineUIUtils.getAndScaleInt("Center.arc", 10); return FineUIUtils.getAndScaleInt("Center.arc", 8);
} }
@Override @Override

2
designer-base/src/main/java/com/fine/theme/light/ui/FineReportComponentCompositeUI.java

@ -33,7 +33,7 @@ public class FineReportComponentCompositeUI extends FlatPanelUI {
@Override @Override
protected void installDefaults(JPanel p) { protected void installDefaults(JPanel p) {
super.installDefaults(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 @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
if (isGroupButtonNotFit(c) || isTabButton(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); super.paint(g, c);
} }
@ -134,7 +134,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
// paint background // paint background
Color background; Color background;
if(c.isEnabled() && selected) { if (c.isEnabled() && selected) {
background = tabSelectedBackground; background = tabSelectedBackground;
} else { } else {
Color enabledColor = selected ? clientPropertyColor(c, TAB_BUTTON_SELECTED_BACKGROUND, tabSelectedBackground) : null; 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); float focusWidth = FlatUIUtils.getBorderFocusWidth(c);
FlatUIUtils.paintComponentBackground(g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0); FlatUIUtils.paintComponentBackground(g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0);
} else { } else {
float arc = FlatUIUtils.getBorderArc( c ) / 2; g2.fill(getGroupButtonPath2D(c, position, FlatUIUtils.getBorderArc(c)));
Shape path2D = getGroupButtonPath2D(c, position, arc);
g2.fill(path2D);
} }
} finally { } finally {
g2.dispose(); g2.dispose();
@ -209,7 +207,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
@Override @Override
protected Color getForeground(JComponent c) { protected Color getForeground(JComponent c) {
if (isGroupButton(c) && ((AbstractButton)c).isSelected()) { if (isGroupButton(c) && ((AbstractButton) c).isSelected()) {
return groupSelectedForeground; return groupSelectedForeground;
} }
return super.getForeground(c); return super.getForeground(c);
@ -218,7 +216,7 @@ public class FineToggleButtonUI extends FlatToggleButtonUI {
@Override @Override
protected Color getBackground(JComponent c) { protected Color getBackground(JComponent c) {
if (isGroupButton(c)) { if (isGroupButton(c)) {
return ((AbstractButton)c).isSelected() ? groupSelectedBackground : groupBackground; return ((AbstractButton) c).isSelected() ? groupSelectedBackground : groupBackground;
} }
return super.getBackground(c); 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 background 背景色
* @param width 宽度 * @param width 宽度
* @param height 高度 * @param height 高度
* @param radius 圆角 * @param arc 圆角
*/ */
public static void paintWithComposite(Graphics g, Composite composite, Color background, 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; Graphics2D g2d = (Graphics2D) g;
FlatUIUtils.setRenderingHints(g2d); FlatUIUtils.setRenderingHints(g2d);
@ -197,7 +197,7 @@ public class FineUIUtils {
g2d.setComposite(composite); g2d.setComposite(composite);
g2d.setColor(background); 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); g2d.setComposite(oldComposite);
} }
@ -247,14 +247,14 @@ public class FineUIUtils {
case LEFT: { case LEFT: {
path2D.append(createLeftRoundRectangle(x, y, width, height, arc), false); path2D.append(createLeftRoundRectangle(x, y, width, height, arc), false);
path2D.append(createLeftRoundRectangle(x + t, y + t, 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; break;
} }
case RIGHT: case RIGHT:
default: { default: {
path2D.append(createRightRoundRectangle(x, y, width, height, arc), false); path2D.append(createRightRoundRectangle(x, y, width, height, arc), false);
path2D.append(createRightRoundRectangle(x + (closedPath ? t : 0), y + t, 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; break;
} }
} }
@ -280,12 +280,18 @@ public class FineUIUtils {
float t2x = t * 2; float t2x = t * 2;
Path2D path2D = new Path2D.Float(Path2D.WIND_EVEN_ODD); Path2D path2D = new Path2D.Float(Path2D.WIND_EVEN_ODD);
path2D.append(createTopRoundRectangle(x, y, width, height, arc), false); 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); g2.fill(path2D);
} }
/** /**
* 创建一个部分圆角的矩形路径 * 创建一个部分圆角的矩形路径
* <p>
* 注意
* 在swing中UI的样式的 arc 数值是直径 css border-radius 为半径
* 因此我们配置的 arc 全部为 border-radius 的2倍但是使用 Path2D 绘制时
* 绘制方式其实是使用半径来进行计算的为了保持调用一致对外 API 还是以 arc
* 的形式因此方法内部需要对 arc 进行取半处理
* *
* @param x x坐标 * @param x x坐标
* @param y y坐标 * @param y y坐标
@ -299,16 +305,20 @@ public class FineUIUtils {
*/ */
public static Path2D createPartRoundRectangle(double x, double y, double width, double height, public static Path2D createPartRoundRectangle(double x, double y, double width, double height,
double arcTopLeft, double arcTopRight, double arcBottomRight, double arcBottomLeft) { double arcTopLeft, double arcTopRight, double arcBottomRight, double arcBottomLeft) {
Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD, 7); double radiusTopLeft = arcTopLeft / 2;
path.moveTo(x + arcTopLeft, y); double radiusTopRight = arcTopRight / 2;
path.lineTo(x + width - arcTopRight, y); double radiusBottomLeft = arcBottomLeft / 2;
path.quadTo(x + width, y, x + width, y + arcTopRight); double radiusBottomRight = arcBottomRight / 2;
path.lineTo(x + width, y + height - arcBottomRight); Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD, 10);
path.quadTo(x + width, y + height, x + width - arcBottomRight, y + height); path.moveTo(x + radiusTopLeft, y);
path.lineTo(x + arcBottomLeft, y + height); path.lineTo(x + width - radiusTopRight, y);
path.quadTo(x, y + height, x, y + height - arcBottomLeft); path.quadTo(x + width, y, x + width, y + radiusTopRight);
path.lineTo(x, y + arcTopLeft); path.lineTo(x + width, y + height - radiusBottomRight);
path.quadTo(x, y, x + arcTopLeft, y); 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(); path.closePath();
return path; 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; package com.fr.design.gui.ibutton;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -148,8 +145,4 @@ public class UICombinationButton extends JPanel {
rightButton.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON); rightButton.putClientProperty(BUTTON_TYPE, BUTTON_TYPE_TOOLBAR_BUTTON);
setStyle(rightButton, IN_TOOLBAR_RIGHT); setStyle(rightButton, IN_TOOLBAR_RIGHT);
} }
protected void showPopWindow(JPopupMenu menu) {
GUICoreUtils.showPopupMenu(menu, this, 0, getY() + getHeight() - 3);
}
} }

21
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) { private void showValFieldChange(int value) {
isButtonOrIsTxt = true; isButtonOrIsTxt = true;
showValue = getPreferredValue(value); showValue = getPreferredValue(value);
@ -172,7 +171,7 @@ public class JFormSliderPane extends JPanel {
refreshSlider(); refreshSlider();
} }
private int getPreferredValue(int value){ private int getPreferredValue(int value) {
if (value > FOUR_HUNDRED) { if (value > FOUR_HUNDRED) {
value = FOUR_HUNDRED; value = FOUR_HUNDRED;
} }
@ -182,7 +181,7 @@ public class JFormSliderPane extends JPanel {
return value; return value;
} }
private void refreshShowValueFieldText(){ private void refreshShowValueFieldText() {
showValField.setValue(showValue); showValField.setValue(showValue);
setAdjustButtonStatus(); setAdjustButtonStatus();
} }
@ -211,7 +210,7 @@ public class JFormSliderPane extends JPanel {
slider.setValue(calSliderValue(showValue)); slider.setValue(calSliderValue(showValue));
} }
private void setAdjustButtonStatus(){ private void setAdjustButtonStatus() {
this.downButton.setEnabled(this.showValue > TEN); this.downButton.setEnabled(this.showValue > TEN);
this.upButton.setEnabled(this.showValue < FOUR_HUNDRED); this.upButton.setEnabled(this.showValue < FOUR_HUNDRED);
} }
@ -230,8 +229,10 @@ public class JFormSliderPane extends JPanel {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
int arc = FineUIUtils.getAndScaleInt("Center.arc", 10) / 2; int arc = FineUIUtils.getAndScaleInt("Center.arc", 8);
Path2D roundedPath = FineUIUtils.createPartRoundRectangle(0, 0, this.getWidth(), this.getHeight(), 0, 0, arc, 0); Path2D roundedPath = FineUIUtils.createPartRoundRectangle(0, 0,
this.getWidth(), this.getHeight(),
0, 0, arc, 0);
FlatUIUtils.setRenderingHints(g); FlatUIUtils.setRenderingHints(g);
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
g2.setColor(getBackground()); g2.setColor(getBackground());
@ -292,8 +293,12 @@ public class JFormSliderPane extends JPanel {
showValFieldChange(value); showValFieldChange(value);
} }
/**
public void addValueChangeListener(ChangeListener changeListener){ * 添加值变化监听器
*
* @param changeListener 变化监听器
*/
public void addValueChangeListener(ChangeListener changeListener) {
this.slider.addChangeListener(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; package com.fr.startup.ui;
import java.awt.Color;
/** /**
* created by Harrison on 2022/07/07 * created by Harrison on 2022/07/07
**/ **/
public class StartupPageConstants { 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 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; Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(color); 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()); 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 ----
CheckBox.arc = 4 CheckBox.arc = $Component.arc
CheckBox.margin = 2,0,2,0 CheckBox.margin = 2,0,2,0
CheckBox.iconTextGap = 4 CheckBox.iconTextGap = 4
CheckBox.rollover = true CheckBox.rollover = true
@ -330,7 +330,7 @@ Component.focusWidth = 0
Component.innerFocusWidth = 0.5 Component.innerFocusWidth = 0.5
Component.innerOutlineWidth = 1 Component.innerOutlineWidth = 1
Component.borderWidth = 1 Component.borderWidth = 1
Component.arc = 5 Component.arc = 6
Component.minimumWidth = 64 Component.minimumWidth = 64
# allowed values: chevron or triangle # allowed values: chevron or triangle
Component.arrowType = chevron Component.arrowType = chevron
@ -580,7 +580,7 @@ PopupMenu.background=$background.normal
PopupMenu.scrollArrowColor = @buttonArrowColor PopupMenu.scrollArrowColor = @buttonArrowColor
PopupMenu.borderColor=$border.divider PopupMenu.borderColor=$border.divider
PopupMenu.hoverScrollArrowBackground = darken(@background,5%) PopupMenu.hoverScrollArrowBackground = darken(@background,5%)
PopupMenu.arc=10 PopupMenu.arc=8
#---- PopupMenuSeparator ---- #---- PopupMenuSeparator ----
PopupMenuSeparator.height=5 PopupMenuSeparator.height=5
@ -887,7 +887,7 @@ TemplateTabPane.borderColor = $border.divider
TemplateTabPane.closeHoverBackground = $hover.deep TemplateTabPane.closeHoverBackground = $hover.deep
TemplateTabPane.tabInsets = 4,6,4,6 TemplateTabPane.tabInsets = 4,6,4,6
TemplateTabPane.borderWidth = 1 TemplateTabPane.borderWidth = 1
TemplateTabPane.tabArc = 5 TemplateTabPane.tabArc = 8
TemplateTabPane.separatorHeight = 14 TemplateTabPane.separatorHeight = 14
TemplateTabPane.icon.hoverBackground = #B8BFCB TemplateTabPane.icon.hoverBackground = #B8BFCB
@ -1206,7 +1206,7 @@ Center.GridColumnRowEditedColor=#e9ecf1
Center.GridCornerFill=fade(#0A1C38, 47%) Center.GridCornerFill=fade(#0A1C38, 47%)
Center.SpaceColor = #FFF Center.SpaceColor = #FFF
Center.border = 0, 10, 10, 10 Center.border = 0, 10, 10, 10
Center.arc=10 Center.arc=8
#---- CellOtherSetPane ---- #---- CellOtherSetPane ----
CellOtherSetPane.height=$Component.defaultHeight CellOtherSetPane.height=$Component.defaultHeight

26
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(){ listener = new ComponentAdapter() {
@Override public void componentResized(ComponentEvent e) { @Override
public void componentResized(ComponentEvent e) {
for (int i = 0; i < lastOneIndex * NUM; i++) { for (int i = 0; i < lastOneIndex * NUM; i++) {
moveLeft(); moveLeft();
} }
@ -328,9 +329,10 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
/** /**
* 抽出来方便OEM * 抽出来方便OEM
*
* @return * @return
*/ */
public Icon getAddWorkSheet(){ public Icon getAddWorkSheet() {
return ADD_WORK_SHEET; 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) { private void paintBackgroundAndLine(Graphics2D g2d, double textHeight, double maxWidth, int charWidth, int textAscent) {
int arc = FineUIUtils.getAndScaleInt("Center.arc", 10) / 2; int arc = FineUIUtils.getAndScaleInt("Center.arc", 8);
Path2D roundedPath = FineUIUtils.createPartRoundRectangle(0, 0, this.getWidth(), this.getHeight(), 0, 0, 0, arc); Path2D roundedPath = FineUIUtils.createPartRoundRectangle(0, 0,
this.getWidth(), this.getHeight(),
0, 0, 0, arc);
FlatUIUtils.setRenderingHints(g2d); FlatUIUtils.setRenderingHints(g2d);
g2d.setColor(getBackground()); g2d.setColor(getBackground());
g2d.fill(roundedPath); g2d.fill(roundedPath);
@ -415,7 +419,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
paintAddButton(g2d); paintAddButton(g2d);
} }
protected void paintAddButton(Graphics2D g2d){ protected void paintAddButton(Graphics2D g2d) {
getAddWorkSheet().paintIcon(this, g2d, iconLocation, 3); getAddWorkSheet().paintIcon(this, g2d, iconLocation, 3);
ADD_POLY_SHEET.paintIcon(this, g2d, iconLocation + getAddWorkSheet().getIconWidth() + iconSepDistance, 3); ADD_POLY_SHEET.paintIcon(this, g2d, iconLocation + getAddWorkSheet().getIconWidth() + iconSepDistance, 3);
} }
@ -569,7 +573,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
} }
} }
private void processRightMouseButton(int evtX, int evtY){ private void processRightMouseButton(int evtX, int evtY) {
MenuDef def = new MenuDef(); MenuDef def = new MenuDef();
addInsertGridShortCut(def); addInsertGridShortCut(def);
def.addShortCut(new PolyReportInsertAction(), SeparatorDef.DEFAULT, new RemoveSheetAction(), new RenameSheetAction(), def.addShortCut(new PolyReportInsertAction(), SeparatorDef.DEFAULT, new RemoveSheetAction(), new RenameSheetAction(),
@ -579,7 +583,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
GUICoreUtils.showPopupMenu(tabPop, this, evtX - 1, evtY - 1); 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)) { 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)) { } else if (evtX > iconLocation + scale(POLY_TOSHEET_LEFT) && evtX < iconLocation + scale(POLY_TOSHEET_RIGHT)) {
@ -588,11 +592,11 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
} }
protected void addInsertGridShortCut(MenuDef def){ protected void addInsertGridShortCut(MenuDef def) {
def.addShortCut(new GridReportInsertAction()); def.addShortCut(new GridReportInsertAction());
} }
protected void firstInsertActionPerformed(){ protected void firstInsertActionPerformed() {
new GridReportInsertAction().actionPerformed(null); new GridReportInsertAction().actionPerformed(null);
} }
@ -746,7 +750,7 @@ public class SheetNameTabPane extends JPanel implements MouseListener, MouseMoti
scrollIndex++; scrollIndex++;
} }
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
TemplateTheme theme = template.getTemplateTheme(); TemplateTheme theme = template.getTemplateTheme();
TemplateReport templateReport = newTemplateReport(); TemplateReport templateReport = newTemplateReport();

34
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.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.font.FontRenderContext; import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
/** /**
@ -31,14 +32,14 @@ import java.awt.geom.Rectangle2D;
* @since 2012-3-22下午5:54:21 * @since 2012-3-22下午5:54:21
*/ */
public class GridRowUI extends ComponentUI { 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 editedBackground = UIManager.getColor("Center.GridColumnRowEditedColor");
protected Color selectedBackground = UIManager.getColor("Center.GridColumnRowSelectedColor"); protected Color selectedBackground = UIManager.getColor("Center.GridColumnRowSelectedColor");
private int resolution ; private final int resolution;
GridRowUI(int resolution){ GridRowUI(int resolution) {
if (resolution == 0){ if (resolution == 0) {
resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
} }
this.resolution = resolution; this.resolution = resolution;
@ -49,12 +50,12 @@ public class GridRowUI extends ComponentUI {
if (!(c instanceof GridRow)) { if (!(c instanceof GridRow)) {
throw new IllegalArgumentException("The component c to paint must be a GridColumn!"); 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; GridRow gridRow = (GridRow) c;
ElementCasePane reportPane = gridRow.getElementCasePane(); ElementCasePane reportPane = gridRow.getElementCasePane();
// size // size
Dimension size = gridRow.getSize(); 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)); g2d.setFont(gridRow.getFont().deriveFont(gridRow.getFont().getSize2D() * time));
ElementCase elementCase = reportPane.getEditingElementCase(); ElementCase elementCase = reportPane.getEditingElementCase();
@ -135,7 +136,7 @@ public class GridRowUI extends ComponentUI {
paintText += "(F)"; 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 private void drawNormalContent(Graphics2D g2d, GridRow gridRow, String paintText,
, ElementCase elementCase, Dimension size, double tmpHeight1) { double increaseHeight, boolean isSelectedBounds,
Dimension size, double y) {
// FontMetrics // FontMetrics
FontRenderContext fontRenderContext = g2d.getFontRenderContext(); FontRenderContext fontRenderContext = g2d.getFontRenderContext();
float time = (float)resolution/DesignerUIModeConfig.getInstance().getScreenResolution(); 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 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) { if (isSelectedBounds) {
g2d.setColor(gridRow.getSelectedForeground()); g2d.setColor(gridRow.getSelectedForeground());
} else { } 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