Browse Source

REPORT-107973 主页及组件视觉样式翻新

【问题原因】rt
【改动思路】为新增key添加默认值
newui
Leo.Qin 11 months ago
parent
commit
a1eb39fcc1
  1. 7
      designer-base/src/main/java/com/fine/theme/light/ui/FineInputUI.java
  2. 2
      designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java
  3. 7
      designer-base/src/main/java/com/fine/theme/light/ui/FineTooltipUI.java
  4. 17
      designer-base/src/main/java/com/fine/theme/utils/FineUIUtils.java
  5. 24
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/FineSearchPane.java
  6. 13
      designer-base/src/main/java/com/fr/design/foldablepane/HeaderPane.java
  7. 8
      designer-base/src/main/java/com/fr/design/gui/frpane/UINumberDragPane.java
  8. 25
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  9. 6
      designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java
  10. 7
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  11. 17
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java
  12. 1
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties

7
designer-base/src/main/java/com/fine/theme/light/ui/FineInputUI.java

@ -1,6 +1,6 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatButtonUI;
import com.formdev.flatlaf.ui.FlatPanelUI;
@ -12,7 +12,7 @@ import javax.swing.plaf.ComponentUI;
import java.beans.PropertyChangeEvent;
/**
* Input输入框 UI类
* Input输入框类组件 UI类
*
* @author Leo.Qin
* @since 11.0
@ -22,6 +22,7 @@ public class FineInputUI extends FlatPanelUI {
private static final String ENABLED = "enabled";
private static final String EDITABLE = "editable";
private final int defaultArc = 5;
public FineInputUI(boolean shared) {
super(shared);
@ -44,7 +45,7 @@ public class FineInputUI extends FlatPanelUI {
@Override
protected void installDefaults(JPanel p) {
super.installDefaults(p);
arc = FineUIScale.scale(UIManager.getInt("Input.arc"));
arc = FineUIUtils.getAndScaleInt("Input.arc", defaultArc);
}
@Override

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

@ -41,7 +41,7 @@ public class FineLightIconSet extends AbstractIconSet {
// 数据集相关Icon
new SvgIconSource("database", "com/fine/theme/icon/dataset/database.svg", true),
new SvgIconSource("preview", "com/fine/theme/icon/dataset/preview.svg", true),
new SvgIconSource("connection", "com/fine/theme/icon/dataset/connection.svg", true),
new SvgIconSource("connection", "com/fine/theme/icon/dataset/connection.svg"),
new SvgIconSource("class_table_data", "com/fine/theme/icon/dataset/class_table_data.svg", true),
new SvgIconSource("data_table", "com/fine/theme/icon/dataset/data_table.svg", true),
new SvgIconSource("multi", "com/fine/theme/icon/dataset/multi.svg", true),

7
designer-base/src/main/java/com/fine/theme/light/ui/FineTooltipUI.java

@ -1,6 +1,7 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatToolTipUI;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.base.BaseUtils;
@ -26,6 +27,8 @@ import java.util.List;
* Created on 2023/12/8
*/
public class FineTooltipUI extends FlatToolTipUI {
private final int defaultMaxWidth = 392;
private final int defaultArc = 5;
private int maxWidth;
private int arc;
private List<String> lines;
@ -70,8 +73,8 @@ public class FineTooltipUI extends FlatToolTipUI {
protected void installDefaults(JComponent c) {
super.installDefaults(c);
c.setOpaque(false);
arc = FineUIScale.scale(UIManager.getInt("ToolTip.arc"));
maxWidth = FineUIScale.scale(UIManager.getInt("ToolTip.maxWidth"));
arc = FineUIScale.scale(FineUIUtils.getAndScaleInt("ToolTip.arc", defaultArc));
maxWidth = FineUIUtils.getAndScaleInt("ToolTip.maxWidth", defaultMaxWidth);
}

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

@ -6,12 +6,12 @@ import com.fr.value.AtomicClearableLazyValue;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Composite;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.geom.RoundRectangle2D;
import java.lang.reflect.Field;
@ -142,6 +142,19 @@ public class FineUIUtils {
return (margin != null) ? margin : defaultInsets;
}
/**
* 通过key获取UI的边距如果没有则使用后备边距并根据dpi进行缩放
*
* @param key 边距key
* @param defaultInsets 后备边距
* @return 根据dpi缩放后的边距
*/
public static Insets getAndScaleUIInsets(String key, Insets defaultInsets) {
Insets margin = UIManager.getInsets(key);
Insets insets = (margin != null) ? margin : defaultInsets;
return FineUIScale.scale(insets);
}
/**
* 绘制混合图像含圆角背景色设置
*

24
designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/FineSearchPane.java

@ -2,7 +2,7 @@ package com.fr.design.data.datapane.management.search.pane;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineInputUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.fr.design.event.HoverAware;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
@ -10,7 +10,6 @@ import com.fr.design.gui.itextfield.UITextField;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
import java.awt.Insets;
@ -28,14 +27,23 @@ import java.awt.event.MouseEvent;
*/
public class FineSearchPane extends JPanel implements HoverAware {
private final Insets defaultLabelInsets = new Insets(3, 6, 3, 4);
private final Insets defaultButtonInsets = new Insets(4, 4, 4, 4);
private UITextField searchTextField;
private UIButton clearButton;
private static final String UI_CLASS_ID = "InputUI";
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
private boolean hover;
public FineSearchPane() {
this.setLayout(new BorderLayout());
this.setUI(new FineInputUI(false));
initComponents();
}
@ -43,9 +51,8 @@ public class FineSearchPane extends JPanel implements HoverAware {
private void initComponents() {
// 左侧搜索图标
UILabel searchLabel = new UILabel(new LazyIcon("search"));
Insets labelInsets = UIManager.getInsets("SearchPanel.labelBorderInsets");
Insets scaledInsets = FineUIScale.scale(labelInsets);
searchLabel.setBorder(BorderFactory.createEmptyBorder(scaledInsets.top, scaledInsets.left, scaledInsets.bottom, scaledInsets.right));
Insets labelInsets = FineUIUtils.getAndScaleUIInsets("SearchPanel.labelBorderInsets", defaultLabelInsets);
searchLabel.setBorder(BorderFactory.createEmptyBorder(labelInsets.top, labelInsets.left, labelInsets.bottom, labelInsets.right));
// 中间输入框
searchTextField = new UITextField();
@ -68,9 +75,8 @@ public class FineSearchPane extends JPanel implements HoverAware {
// 右侧返回图标
clearButton = new UIButton(new LazyIcon("clear"));
clearButton.setUI(new FineInputUI.FineInputButtonUI(false));
Insets buttonInsets = UIManager.getInsets("SearchPanel.buttonBorderInsets");
Insets buttonScaledInsets = FineUIScale.scale(buttonInsets);
clearButton.setBorder(BorderFactory.createEmptyBorder(buttonScaledInsets.top, buttonScaledInsets.left, buttonScaledInsets.bottom, buttonScaledInsets.right));
Insets buttonInsets = FineUIUtils.getAndScaleUIInsets("SearchPanel.buttonBorderInsets", defaultButtonInsets);
clearButton.setBorder(BorderFactory.createEmptyBorder(buttonInsets.top, buttonInsets.left, buttonInsets.bottom, buttonInsets.right));
this.add(searchLabel, BorderLayout.WEST);
this.add(searchTextField, BorderLayout.CENTER);

13
designer-base/src/main/java/com/fr/design/foldablepane/HeaderPane.java

@ -2,6 +2,7 @@ package com.fr.design.foldablepane;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.fr.base.GraphHelper;
import javax.swing.BorderFactory;
@ -24,6 +25,9 @@ import java.awt.Insets;
*/
public class HeaderPane extends JPanel {
private static final long serialVersionUID = 1L;
private final Insets defaultInsets = new Insets(0, 6, 0, 6);
private final int defaultWidth = 248;
private final int defaultHeight = 24;
private int headWidth;
private int headHeight;
private Color bgColor;
@ -88,12 +92,13 @@ public class HeaderPane extends JPanel {
this.isShow = true;
triangleDown = new LazyIcon("triangle_down");
triangleRight = new LazyIcon("triangle_right");
this.setPreferredSize(FineUIScale.scale(new Dimension(UIManager.getInt("HeaderPane.width"), UIManager.getInt("HeaderPane.height"))));
Insets insets = UIManager.getInsets("ExpandablePane.HeaderPane.borderInsets");
Insets scaledInsets = FineUIScale.scale(insets);
int width = FineUIUtils.getAndScaleInt("HeaderPane.width", defaultWidth);
int height = FineUIUtils.getAndScaleInt("HeaderPane.height", defaultHeight);
this.setPreferredSize(new Dimension(width, height));
Insets insets = FineUIUtils.getAndScaleUIInsets("ExpandablePane.HeaderPane.borderInsets", defaultInsets);
this.setForeground(UIManager.getColor("ExpandablePane.HeaderPane.foreground"));
this.setFont(getFont().deriveFont(Font.BOLD));
this.setBorder(BorderFactory.createEmptyBorder(scaledInsets.top, scaledInsets.left, scaledInsets.bottom, scaledInsets.right));
this.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right));
}
public HeaderPane(Color bgColor, String title, int headHeight) {

8
designer-base/src/main/java/com/fr/design/gui/frpane/UINumberDragPane.java

@ -3,8 +3,8 @@ package com.fr.design.gui.frpane;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.gui.islider.UISlider;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.style.NumberDragBar;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@ -14,7 +14,7 @@ import java.awt.Dimension;
public class UINumberDragPane extends BasicBeanPane<Double> implements GlobalNameObserver {
private static final long serialVersionUID = -8681716725163358249L;
private NumberDragBar dragBar;
private UISlider dragBar;
private UISpinner spinner;
private boolean isEditing = false;
private String numberDargPaneName = "";
@ -33,7 +33,9 @@ public class UINumberDragPane extends BasicBeanPane<Double> implements GlobalNam
}
public UINumberDragPane(double minValue, double maxValue, double dierta) {
dragBar = new NumberDragBar((int) minValue, (int) maxValue);
dragBar = new UISlider((int) minValue, (int) maxValue);
dragBar.setPaintLabels(true);
dragBar.setMajorTickSpacing((int) maxValue);
spinner = createUISpinner(minValue, maxValue, dierta);
spinner.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_StyleAlignment_Text_Rotation"));
this.setLayout(new BorderLayout(4, 0));

25
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -3,6 +3,7 @@ package com.fr.design.gui.ispinner;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineInputUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.HoverAware;
@ -44,6 +45,8 @@ import java.awt.event.MouseWheelListener;
*/
public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver, HoverAware {
private final Insets defaultInsets = new Insets(0, 6, 0, 6);
private final int defaultButtonSize = 24;
protected double value;
private static final int DEFAULT_NUMBERFIELD_COLUMNS = 2;
private UINumberField textField;
@ -64,6 +67,13 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
private boolean hover;
private static final String UI_CLASS_ID = "InputUI";
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
public UISpinner() {
}
@ -89,7 +99,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
this.dierta = dierta;
initComponents();
iniListener();
setUI(FineInputUI.createUI(this));
}
private void iniListener() {
@ -272,6 +281,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
textField = initNumberField();
textField.setMaxValue(maxValue);
textField.setMinValue(minValue);
Insets insets = FineUIUtils.getAndScaleUIInsets("InputTextField.borderInsets", defaultInsets);
textField.setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right));
textField.setOpaque(false);
setValue(value);
preButton = createArrowButton(new LazyIcon("up_arrow_12"));
nextButton = createArrowButton(new LazyIcon("down_arrow_12"));
@ -283,9 +296,9 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
arrowPane.add(nextButton);
arrowPane.setOpaque(false);
int buttonWidth = UIManager.getInt("InputButton.width");
int buttonHeight = UIManager.getInt("InputButton.height");
arrowPane.setPreferredSize(FineUIScale.scale(new Dimension(buttonWidth, buttonHeight)));
int buttonWidth = FineUIUtils.getAndScaleInt("InputButton.width", defaultButtonSize);
int buttonHeight = FineUIUtils.getAndScaleInt("InputButton.height", defaultButtonSize);
arrowPane.setPreferredSize(new Dimension(buttonWidth, buttonHeight));
add(arrowPane, BorderLayout.EAST);
componentInitListeners();
}
@ -370,10 +383,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver,
return false;
}
};
Insets insets = UIManager.getInsets("InputTextField.borderInsets");
Insets scaledInsets = FineUIScale.scale(insets);
numberField.setBorder(BorderFactory.createEmptyBorder(scaledInsets.top, scaledInsets.left, scaledInsets.bottom, scaledInsets.right));
numberField.setOpaque(false);
return numberField;
}

6
designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java

@ -1,6 +1,6 @@
package com.fr.design.gui.itextfield;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
@ -14,7 +14,6 @@ import com.fr.stable.StringUtils;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
@ -33,6 +32,7 @@ import java.awt.event.MouseEvent;
* @since xxx
*/
public class UITextField extends JTextField implements UIObserver, GlobalNameObserver, HoverAware {
private final int defaultHeight = 24;
private boolean isBorderPainted = true;
private boolean isRoundBorder = true;
private int rectDirection = Constants.NULL;
@ -243,6 +243,6 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
@Override
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, FineUIScale.scale(UIManager.getInt("Input.height")));
return new Dimension(super.getPreferredSize().width, FineUIUtils.getAndScaleInt("Input.height", defaultHeight));
}
}

7
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.RectangleButtonUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.ui.FlatLineBorder;
import com.fr.base.FRContext;
@ -1171,6 +1172,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 弹出属性面板的工具条
private class PopupToolPane extends JPanel {
private final UIButton popupButton;
private final Insets defaultInsets = new Insets(0, 10, 0, 10);
private String title;
private PropertyItem propertyItem;
private String buttonType;
@ -1263,9 +1265,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
popupButton = createPopupButton(buttonType);
contentPane.add(popupButton, BorderLayout.EAST);
Insets insets = UIManager.getInsets("PopupToolPane.borderInsets");
Insets scaledInsets = FineUIScale.scale(insets);
contentPane.setBorder(new EmptyBorder(scaledInsets.top, scaledInsets.left, scaledInsets.bottom, scaledInsets.right));
Insets insets = FineUIUtils.getAndScaleUIInsets("PopupToolPane.borderInsets", defaultInsets);
contentPane.setBorder(new EmptyBorder(insets.top, insets.left, insets.bottom, insets.right));
setLayout(new BorderLayout());
add(contentPane, BorderLayout.CENTER);

17
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.widget.accessibles;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineInputUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.fr.design.Exception.ValidationException;
import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder;
@ -39,6 +40,7 @@ import java.util.ArrayList;
*/
public class BaseAccessibleEditor extends BasicPane implements AccessibleEditor, HoverAware {
private final Insets defaultInsets = new Insets(0, 6, 0, 6);
private ArrayList<ChangeListener> listeners;
private boolean showButton;
protected Encoder encoder;
@ -47,6 +49,13 @@ public class BaseAccessibleEditor extends BasicPane implements AccessibleEditor,
protected ITextComponent txtValue;
private boolean hover;
private static final String UI_CLASS_ID = "InputUI";
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
public BaseAccessibleEditor(Encoder enc, Decoder dec, boolean showBtn) {
listeners = new ArrayList<ChangeListener>();
this.showButton = showBtn;
@ -56,12 +65,8 @@ public class BaseAccessibleEditor extends BasicPane implements AccessibleEditor,
initListener();
txtValue.setEditable(dec != null);
((JComponent) txtValue).setOpaque(false);
Insets insets = UIManager.getInsets("InputTextField.borderInsets");
Insets scaledInsets = FineUIScale.scale(insets);
((JComponent) txtValue).setBorder(BorderFactory.createEmptyBorder(scaledInsets.top, scaledInsets.left, scaledInsets.bottom, scaledInsets.right));
this.setUI(FineInputUI.createUI(this));
setPreferredSize(new Dimension(getPreferredSize().width, FineUIScale.scale(UIManager.getInt("Input.height"))));
Insets insets = FineUIUtils.getAndScaleUIInsets("InputTextField.borderInsets", defaultInsets);
((JComponent) txtValue).setBorder(BorderFactory.createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right));
}
private void initListener() {

1
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties

@ -46,4 +46,5 @@ ViewportUI=com.formdev.flatlaf.ui.FlatViewportUI
HeadGroupUI=com.fine.theme.light.ui.FineHeadGroupUI
ButtonGroupUI= com.fine.theme.light.ui.FineButtonGroupUI
SelectBoxUI= com.fine.theme.light.ui.FineSelectBoxUI
InputUI=com.fine.theme.light.ui.FineInputUI
GradientBarUI=com.fine.theme.light.ui.FineGradientBarUI
Loading…
Cancel
Save