Browse Source

REPORT-107972 设计器样式翻新-RadioButton和ScrollBar翻新

newui
Levy.Xie-解安森 1 year ago
parent
commit
857cdb3a3e
  1. 4
      designer-base/src/main/java/com/fine/theme/light/ui/FineLightIconSet.java
  2. 92
      designer-base/src/main/java/com/fine/theme/light/ui/ReportScrollBarUI.java
  3. 11
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java
  4. 34
      designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBar.java
  5. 20
      designer-base/src/main/resources/com/fine/theme/icon/radio/radio_selected.svg
  6. 6
      designer-base/src/main/resources/com/fine/theme/icon/radio/radio_unselected.svg
  7. 46
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  8. 7
      designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollBar.java

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

@ -111,6 +111,10 @@ public class FineLightIconSet extends AbstractIconSet {
new SvgIconSource("checkbox_part_checked", "com/fine/theme/icon/checkbox/part_checked.svg", true),
new SvgIconSource("checkbox_hovered", "com/fine/theme/icon/checkbox/hovered.svg", true),
// radioButton相关icon
new SvgIconSource("radio_selected", "com/fine/theme/icon/radio/radio_selected.svg", true),
new SvgIconSource("radio_unselected", "com/fine/theme/icon/radio/radio_unselected.svg", true),
// 菜单栏Icon
new SvgIconSource("bold", "com/fine/theme/icon/font/bold.svg"),
new SvgIconSource("italic", "com/fine/theme/icon/font/italic.svg"),

92
designer-base/src/main/java/com/fine/theme/light/ui/ReportScrollBarUI.java

@ -0,0 +1,92 @@
package com.fine.theme.light.ui;
import com.formdev.flatlaf.ui.FlatScrollBarUI;
import com.formdev.flatlaf.ui.FlatUIUtils;
import javax.swing.JComponent;
import javax.swing.JButton;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
/**
* 应用于主面板报表工作区的滚动条UI提供给 {@link com.fr.design.cell.bar.DynamicScrollBar} 的UI类
*
* @author Levy.Xie
* @since 11.0`
* Created on 2023/12/08
*/
public class ReportScrollBarUI extends FlatScrollBarUI {
/**
* 创建UI类
*
* @param c 组件
* @return ReportScrollBarUI
*/
public static ComponentUI createUI(JComponent c) {
return new ReportScrollBarUI();
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
scrollBarWidth = UIManager.getInt("ScrollBar.largeBar.width");
thumbInsets = UIManager.getInsets("ScrollBar.largeBar.thumbInsets");
showButtons = UIManager.getBoolean("ScrollBar.largeBar.showButtons");
trackColor = UIManager.getColor("ScrollBar.largeBar.track");
}
@Override
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
}
@Override
protected JButton createDecreaseButton(int orientation) {
return new ReportScrollBarButton(orientation);
}
@Override
protected JButton createIncreaseButton(int orientation) {
return new ReportScrollBarButton(orientation);
}
protected class ReportScrollBarButton extends FlatScrollBarButton {
protected final Color defaultButtonBackground = UIManager.getColor("ScrollBar.largeBar.buttonBackground");
protected ReportScrollBarButton(int direction) {
super(direction);
}
@Override
public void paint(Graphics g) {
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints(g);
// paint hover or pressed background
if (isEnabled()) {
Color background = (pressedBackground != null && isPressed())
? pressedBackground
: (hoverBackground != null && isHover()
? hoverBackground
: null);
if (background == null) {
background = defaultButtonBackground;
}
g.setColor(deriveBackground(background));
paintBackground((Graphics2D) g);
}
// paint arrow
g.setColor(deriveForeground(getArrowColor()));
paintArrow((Graphics2D) g);
FlatUIUtils.resetRenderingHints(g, oldRenderingHints);
}
}
}

11
designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java

@ -1,5 +1,6 @@
package com.fr.design.gui.ibutton;
import com.fine.theme.icon.LazyIcon;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
@ -18,6 +19,11 @@ import java.awt.event.ItemListener;
* Time: 下午5:04
*/
public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNameObserver {
private static final Icon RADIO_SELECTED = new LazyIcon("radio_selected");
private static final Icon RADIO_UNSELECTED = new LazyIcon("radio_unselected");
private static final int RADIO_V_GAP = UIManager.getInt("RadioButton.vGap");
private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null;
private String radioButtonName = StringUtils.EMPTY;
@ -106,6 +112,9 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam
private void initComponent() {
this.setFocusPainted(false);
this.setIcon(RADIO_UNSELECTED);
this.setSelectedIcon(RADIO_SELECTED);
this.setBorder(BorderFactory.createEmptyBorder(RADIO_V_GAP, 0, RADIO_V_GAP, 0));
}
/**
@ -137,6 +146,7 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam
/**
* 注册观察者监听事件
*
* @param listener 观察者监听事件
*/
public void registerNameListener(GlobalNameListener listener) {
@ -145,6 +155,7 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam
/**
* 组件是否需要响应观察者事件
*
* @return 如果需要响应观察者事件则返回true否则返回false
*/
public boolean shouldResponseNameListener() {

34
designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBar.java

@ -1,7 +1,6 @@
package com.fr.design.gui.iscrollbar;
import javax.swing.*;
import java.awt.*;
/**
* UIScrollBar是没有下上的按钮的,宽为8像素
@ -11,44 +10,13 @@ import java.awt.*;
*/
public class UIScrollBar extends JScrollBar {
/**
*
*/
private static final long serialVersionUID = 1L;
private int temp = 10;
public UIScrollBar(){
public UIScrollBar() {
}
public UIScrollBar(int orientation) {
super(orientation);
}
@Override
public Dimension getPreferredSize() {
return getOrientation() == UIScrollBar.VERTICAL ?
new Dimension(10, super.getPreferredSize().height)
: new Dimension(super.getPreferredSize().width, 10);
}
@Override
public void setBackground(Color bg) {
super.setBackground(bg);
}
@Override
/**
* 取得宽度
*/
public int getWidth() {
return getOrientation() == UIScrollBar.VERTICAL ? temp : super.getWidth();
}
@Override
/**
* 取得高度
*/
public int getHeight() {
return getOrientation() == UIScrollBar.HORIZONTAL ? temp : super.getHeight();
}
}

20
designer-base/src/main/resources/com/fine/theme/icon/radio/radio_selected.svg

@ -0,0 +1,20 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="&#229;&#141;&#149;&#233;&#128;&#137;&#38;&#229;&#164;&#154;&#233;&#128;&#137;">
<path id="Rectangle 44" d="M1.5 8C1.5 4.41015 4.41015 1.5 8 1.5C11.5899 1.5 14.5 4.41015 14.5 8C14.5 11.5899 11.5899 14.5 8 14.5C4.41015 14.5 1.5 11.5899 1.5 8Z" fill="#2576EF"/>
<path id="Rectangle 44 (Stroke)" fill-rule="evenodd" clip-rule="evenodd" d="M2.5 8C2.5 11.0376 4.96243 13.5 8 13.5C11.0376 13.5 13.5 11.0376 13.5 8C13.5 4.96243 11.0376 2.5 8 2.5C4.96243 2.5 2.5 4.96243 2.5 8ZM8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2Z" fill="#2576EF"/>
<g id="Rectangle 44_2" filter="url(#filter0_d_6332_52602)">
<rect x="4.5" y="4.5" width="7" height="7" rx="3.5" fill="white"/>
</g>
</g>
<defs>
<filter id="filter0_d_6332_52602" x="3.5" y="4.5" width="9" height="9" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
<feOffset dy="1"/>
<feGaussianBlur stdDeviation="0.5"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.0901961 0 0 0 0 0.341176 0 0 0 0 0.776471 0 0 0 0.5 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_6332_52602"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_6332_52602" result="shape"/>
</filter>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

6
designer-base/src/main/resources/com/fine/theme/icon/radio/radio_unselected.svg

@ -0,0 +1,6 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="&#229;&#141;&#149;&#233;&#128;&#137;&#38;&#229;&#164;&#154;&#233;&#128;&#137;">
<rect id="Rectangle 44" x="1.5" y="1.5" width="13" height="13" rx="6.5" fill="#B8BFCB"/>
<path id="Rectangle 163" d="M2.5 8C2.5 4.96243 4.96243 2.5 8 2.5C11.0376 2.5 13.5 4.96243 13.5 8C13.5 11.0376 11.0376 13.5 8 13.5C4.96243 13.5 2.5 11.0376 2.5 8Z" fill="white"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 462 B

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

@ -137,7 +137,7 @@ Component.defaultHeight=24
@accentButtonDefaultBorderColor = if(@accentColor, @accentColor, tint(@accentBase2Color,20%))
# for buttons within components (e.g. combobox or spinner)
@buttonArrowColor = tint(@foreground,40%)
@buttonArrowColor = #0A1C38
@buttonDisabledArrowColor = lighten(@buttonArrowColor,25%)
@buttonHoverArrowColor = lighten(@buttonArrowColor,20%,derived noAutoInverse)
@buttonPressedArrowColor = lighten(@buttonArrowColor,30%,derived noAutoInverse)
@ -298,7 +298,7 @@ ComboBox.buttonBackground = $ComboBox.background
ComboBox.buttonEditableBackground = darken($ComboBox.background,2%)
ComboBox.buttonSeparatorColor = $ComboBox.background
ComboBox.buttonDisabledSeparatorColor = $Component.disabledBorderColor
ComboBox.buttonArrowColor = #0A1C38
ComboBox.buttonArrowColor = @buttonArrowColor
ComboBox.buttonDisabledArrowColor = @buttonDisabledArrowColor
ComboBox.buttonHoverArrowColor = #0A1C38
ComboBox.buttonPressedArrowColor = #0A1C38
@ -601,13 +601,14 @@ ProgressBar.selectionForeground = contrast($ProgressBar.foreground, @foreground,
#---- RadioButton ----
RadioButton.border = com.formdev.flatlaf.ui.FlatMarginBorder
RadioButton.icon = com.formdev.flatlaf.icons.FlatRadioButtonIcon
RadioButton.icon.centerDiameter = 8
RadioButton.icon[filled].centerDiameter = 5
RadioButton.margin = 2,2,2,2
#RadioButton.border = com.formdev.flatlaf.ui.FlatMarginBorder
#RadioButton.icon = com.formdev.flatlaf.icons.FlatRadioButtonIcon
#RadioButton.icon.centerDiameter = 8
#RadioButton.icon[filled].centerDiameter = 5
#RadioButton.margin = 2,2,2,2
RadioButton.iconTextGap = 4
RadioButton.rollover = true
RadioButton.vGap = 4
#RadioButton.rollover = true
#---- RadioButtonMenuItem ----
@ -634,39 +635,44 @@ RootPane.inactiveBorderColor = darken(@background,30%,derived)
#---- ScrollBar ----
ScrollBar.width = 16
ScrollBar.width = 10
ScrollBar.minimumButtonSize = 12,12
ScrollBar.minimumThumbSize = 10,10
ScrollBar.minimumThumbSize = 100,100
ScrollBar.maximumThumbSize = 100000,100000
ScrollBar.trackInsets = 0,0,0,0
ScrollBar.thumbInsets = 0,0,0,0
ScrollBar.thumbInsets = 0,2,0,2
ScrollBar.trackArc = 0
ScrollBar.thumbArc = 0
ScrollBar.thumbArc = 999
ScrollBar.hoverThumbWithTrack = false
ScrollBar.pressedThumbWithTrack = false
ScrollBar.showButtons = true
ScrollBar.showButtons = false
ScrollBar.squareButtons = false
ScrollBar.buttonArrowColor = @buttonArrowColor
ScrollBar.buttonDisabledArrowColor = @buttonDisabledArrowColor
ScrollBar.allowsAbsolutePositioning = true
[mac]ScrollBar.minimumThumbSize = 18,18
[mac]ScrollBar.thumbInsets = 2,2,2,2
[mac]ScrollBar.minimumThumbSize = 6,12
[mac]ScrollBar.thumbInsets = 0,2,0,2
[mac]ScrollBar.thumbArc = 999
[mac]ScrollBar.hoverThumbWithTrack = true
[linux]ScrollBar.minimumThumbSize = 18,18
[linux]ScrollBar.thumbInsets = 2,2,2,2
[linux]ScrollBar.minimumThumbSize = 6,12
[linux]ScrollBar.thumbInsets = 2,0,2,0
[linux]ScrollBar.thumbArc = 999
ScrollBar.track = lighten(@background,1%,derived noAutoInverse)
ScrollBar.thumb = darken($ScrollBar.track,10%,derived noAutoInverse)
ScrollBar.track = #00000000
ScrollBar.thumb = #0a1c3833
ScrollBar.hoverTrackColor = darken($ScrollBar.track,3%,derived noAutoInverse)
ScrollBar.hoverThumbColor = darken($ScrollBar.thumb,10%,derived noAutoInverse)
ScrollBar.pressedThumbColor = darken($ScrollBar.thumb,20%,derived noAutoInverse)
ScrollBar.pressedThumbColor = #0a1c3849
ScrollBar.hoverButtonBackground = darken(@background,5%,derived noAutoInverse)
ScrollBar.pressedButtonBackground = darken(@background,10%,derived noAutoInverse)
ScrollBar.largeBar.width = 16
ScrollBar.largeBar.track = #FFF
ScrollBar.largeBar.showButtons = true
ScrollBar.largeBar.thumbInsets = 0,4,0,4
ScrollBar.largeBar.buttonBackground = $ScrollBar.track
#---- ScrollPane ----

7
designer-realize/src/main/java/com/fr/design/cell/bar/DynamicScrollBar.java

@ -3,6 +3,7 @@
*/
package com.fr.design.cell.bar;
import com.fine.theme.light.ui.ReportScrollBarUI;
import com.fr.base.DynamicUnitList;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.GridUtils;
@ -35,6 +36,7 @@ public class DynamicScrollBar extends JScrollBar {
this.setMinimum(0);
this.setUnitIncrement(1);
this.setBlockIncrement(3);
this.setUI(new ReportScrollBarUI());
this.addComponentListener(new ComponentListener() {
public void componentResized(ComponentEvent e) {
@ -98,11 +100,6 @@ public class DynamicScrollBar extends JScrollBar {
}
}
// public void updateUI() {
// setUI(new DynamicScrollBarUI());
// }
@Override
public void setValue(int value) {
if (reportPane == null) {

Loading…
Cancel
Save