Browse Source
Merge in DESIGN/design from ~LEVY.XIE/design:newui to newui * commit '857cdb3a3e239a9d5625066f1eb79585a68ffe63': REPORT-107972 设计器样式翻新-RadioButton和ScrollBar翻新newui
Levy.Xie-解安森
12 months ago
8 changed files with 167 additions and 63 deletions
@ -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); |
||||
} |
||||
} |
||||
|
||||
} |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 462 B |
Loading…
Reference in new issue