Browse Source

REPORT-107972 设计器样式翻新-翻新按钮组

newui
Levy.Xie-解安森 11 months ago
parent
commit
3930b44c70
  1. 16
      designer-base/src/main/java/com/fine/theme/light/ui/RectangleButtonUI.java
  2. 176
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java
  3. 15
      designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java
  4. 4
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  5. 3
      designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java
  6. 2
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotUITabGroup.java
  7. 46
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java
  8. 4
      designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java

16
designer-base/src/main/java/com/fine/theme/light/ui/PropertiesItemUI.java → designer-base/src/main/java/com/fine/theme/light/ui/RectangleButtonUI.java

@ -7,31 +7,31 @@ import javax.swing.JComponent;
import java.awt.*;
/**
* 东区属性面板属性按钮UI
* 矩形按钮UI忽略圆角属性
*
* @author Levy.Xie
* @since 11.0
* Created on 2023/11/30
*/
public class PropertiesItemUI extends FlatButtonUI {
public class RectangleButtonUI extends FlatButtonUI {
public PropertiesItemUI(boolean shared) {
public RectangleButtonUI(boolean shared) {
super(shared);
}
@Override
protected void paintBackground(Graphics g, JComponent c) {
Color background = getBackground( c );
if( background == null ) {
Color background = getBackground(c);
if (background == null) {
return;
}
Graphics2D g2 = (Graphics2D) g.create();
try {
FlatUIUtils.setRenderingHints( g2 );
FlatUIUtils.setRenderingHints(g2);
g2.setColor(FlatUIUtils.deriveColor(background, getBackgroundBase(c, true)));
float focusWidth = FlatUIUtils.getBorderFocusWidth( c );
FlatUIUtils.paintComponentBackground( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0 );
float focusWidth = FlatUIUtils.getBorderFocusWidth(c);
FlatUIUtils.paintComponentBackground(g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, 0);
} finally {
g2.dispose();
}

176
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java

@ -1,6 +1,8 @@
package com.fr.design.gui.ibutton;
import com.fr.design.constants.UIConstants;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.light.ui.RectangleButtonUI;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
@ -15,14 +17,14 @@ import javax.swing.JPanel;
import javax.swing.border.Border;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.UIManager;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -44,6 +46,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
private String buttonGroupName = StringUtils.EMPTY;
private boolean isToolBarComponent = false;
private boolean isClick;
protected int totalButtonSize = 0;
private UIObserverListener uiObserverListener;
private boolean autoFireStateChanged = true;
@ -65,6 +68,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
this.objectList = Arrays.asList(objects);
}
labelButtonList = new ArrayList<UIToggleButton>(iconArray.length);
totalButtonSize = iconArray.length;
this.setLayout(getGridLayout(iconArray.length));
this.setBorder(getGroupBorder());
for (int i = 0; i < iconArray.length; i++) {
@ -92,7 +96,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
return false;
}
};
initButton(labelButton);
initButton(labelButton, i);
}
}
@ -100,6 +104,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
if (!ArrayUtils.isEmpty(objects) && iconArray.length == objects.length) {
this.objectList = Arrays.asList(objects);
}
totalButtonSize = iconArray.length;
labelButtonList = new ArrayList<UIToggleButton>(iconArray.length);
this.setLayout(getGridLayout(iconArray.length));
this.setBorder(getGroupBorder());
@ -128,7 +133,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
return false;
}
};
initButton(labelButton);
initButton(labelButton, i);
}
}
@ -143,15 +148,14 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
public void setForToolBarButtonGroup(boolean isToolBarComponent) {
this.isToolBarComponent = isToolBarComponent;
if (isToolBarComponent) {
for (int i = 0; i < labelButtonList.size(); i++) {
labelButtonList.get(i).set4ToolbarButton();
for (UIToggleButton uiToggleButton : labelButtonList) {
uiToggleButton.set4ToolbarButton();
}
}
repaint();
}
/**
* setEnabled
*
@ -168,6 +172,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
if (!ArrayUtils.isEmpty(objects) && textArray.length == objects.length) {
this.objectList = Arrays.asList(objects);
}
totalButtonSize = textArray.length;
currentButtonSize = textArray.length;
labelButtonList = new ArrayList<UIToggleButton>(textArray.length);
this.setLayout(getGridLayout(textArray.length));
@ -191,51 +196,102 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
};
}
@Override
public Insets getInsets() {
return new Insets(0, 2, 0, 2);
}
public boolean shouldResponseNameListener() {
return false;
}
};
// labelButton.setUI(new UIButtonUI() {
// protected void paintText(Graphics g, AbstractButton b, String text, Rectangle textRec) {
// View v = (View) b.getClientProperty(BasicHTML.propertyKey);
// if (v != null) {
// v.paint(g, textRec);
// return;
// }
// FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);
// int mnemonicIndex = b.getDisplayedMnemonicIndex();
// if (isPressed(b)) {
// g.setColor(Color.white);
// } else {
// g.setColor(b.isEnabled() ? Color.black : UIConstants.LINE_COLOR);
// }
//
// SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemonicIndex, textRec.x + getTextShiftOffset(), textRec.y + fm.getAscent() + getTextShiftOffset());
// }
// });
initButton(labelButton);
initButton(labelButton, i);
}
}
private static class TabButtonUI extends RectangleButtonUI {
protected int minimumWidth;
protected int minimumHeight;
protected TabButtonUI(boolean shared) {
super(shared);
}
public static ComponentUI createUI(JComponent c) {
return new TabButtonUI(false);
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
background = UIManager.getColor("Button.group.background");
pressedBackground = UIManager.getColor("Button.group.pressedBackground");
selectedBackground = UIManager.getColor("Button.group.selectedBackground");
pressedForeground = UIManager.getColor("Button.group.pressedForeground");
selectedForeground = UIManager.getColor("Button.group.selectedForeground");
minimumWidth = UIManager.getInt("Button.group.minimumWidth");
minimumHeight = UIManager.getInt("Button.group.minimumHeight");
}
@Override
public Dimension getMinimumSize(JComponent c) {
return new Dimension(minimumWidth, minimumHeight);
}
}
public void setGlobalName(String name) {
buttonGroupName = name;
}
protected void initButton(UIToggleButton labelButton) {
labelButton.setBorderPainted(false);
adjustButton(labelButton);
initButton(labelButton, 0);
}
protected void initButton(UIToggleButton labelButton, int buttonIndex) {
labelButton.setUI(new TabButtonUI(false));
paintInnerBorder(labelButton, buttonIndex);
adjustButton(labelButton, buttonIndex);
UIComponentUtils.setLineWrap(labelButton);
labelButtonList.add(labelButton);
this.add(labelButton);
}
private void adjustButton(UIToggleButton labelButton) {
/**
* 绘制按钮组内边框
*
* @param labelButton 按钮
* @param index 按钮序号
*/
protected void paintInnerBorder(UIToggleButton labelButton, int index) {
LayoutManager layout = getLayout();
int leftBorder = 0;
int bottomBorder = 0;
if (layout instanceof GridLayout) {
GridLayout gridLayout = (GridLayout) layout;
int rows = gridLayout.getRows();
int columns = gridLayout.getColumns();
rows = getActualColumnRow(rows, columns, totalButtonSize);
columns = getActualColumnRow(columns, rows, totalButtonSize);
int columnIndex = index % columns;
int rowIndex = index / columns;
// 非首列,绘制左边框
leftBorder = (columnIndex != 0) ? 1 : 0;
// 非末行,绘制底边框
bottomBorder = (rows > 1 && rowIndex < rows - 1) ? 1 : 0;
} else {
leftBorder = (index != 0) ? 1 : 0;
}
labelButton.setBorderPainted((leftBorder | bottomBorder) != 0);
labelButton.setBorder((leftBorder | bottomBorder) != 0 ?
BorderFactory.createMatteBorder(0, leftBorder, bottomBorder, 0, UIManager.getColor("defaultBorderColor")) :
null);
}
private int getActualColumnRow(int origin, int divider, int total) {
return (origin == 0 || divider == 0) ? (int) Math.ceil((double) total / divider) : origin;
}
private void adjustButton(UIToggleButton labelButton, int index) {
if (labelButton.getText().length() > TEXT_LENGTH && currentButtonSize > BUTTON_SIZE) {
Dimension dimension = labelButton.getPreferredSize();
dimension.height <<= 1;
@ -244,24 +300,20 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
}
protected Border getGroupBorder() {
return BorderFactory.createEmptyBorder(1, 1, 1, 1);
return new FineRoundBorder();
}
protected LayoutManager getGridLayout(int number) {
return new GridLayout(0, number, 0, 0);
}
/**
* paintComponent
*
* @param g
*/
public void paintComponents(Graphics g) {
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Shape oldClip = g2d.getClip();
g2d.clip(new RoundRectangle2D.Double(1, 1, getWidth(), getHeight(), UIConstants.ARC, UIConstants.ARC));
super.paintComponents(g);
g2d.setClip(oldClip);
FlatUIUtils.setRenderingHints(g2d);
int arc = UIManager.getInt("Button.group.arc");
g2d.clip(new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), arc, arc));
super.paint(g);
}
public void setAutoFireStateChanged(boolean autoFireStateChanged) {
@ -353,7 +405,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
/**
* 给所有的Button添加Tips
*
* @param tips
* @param tips 标签
*/
public void setAllToolTips(String[] tips) {
for (int i = 0; i < labelButtonList.size(); i++) {
@ -438,34 +490,6 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIOb
fireStateChanged();
}
/**
* 重载Border画法
*
* @param g
*/
@Override
protected void paintBorder(Graphics g) {
if (isToolBarComponent) {
return;
}
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(UIConstants.SHADOW_GREY);
int width = 0;
for (int i = 0; i < labelButtonList.size() - 1; i++) {
width += labelButtonList.get(i).getWidth() + 1;
int height = labelButtonList.get(i).getHeight();
g.drawLine(width, 0, width, height);
}
width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect(0, 0, width, getHeight() - 1, UIConstants.BUTTON_GROUP_ARC, UIConstants.BUTTON_GROUP_ARC);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
/**
* main
*

15
designer-base/src/main/java/com/fr/design/gui/ibutton/UITabGroup.java

@ -1,7 +1,6 @@
package com.fr.design.gui.ibutton;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
public class UITabGroup extends UIButtonGroup<Integer> {
@ -9,8 +8,6 @@ public class UITabGroup extends UIButtonGroup<Integer> {
private boolean isDrawLine = true;
private static final int BUTTON_NUMBER = 5;
private static final int SEVEN_NUMBER = 7;
private static final int ORIGINAL_WIDTH = 10;
private static final int GAP = 11;
/**
* 标签页改变
@ -18,7 +15,7 @@ public class UITabGroup extends UIButtonGroup<Integer> {
* @param index 序号
*/
public void tabChanged(int index) {
return;
}
public UITabGroup(Icon[] iconArray) {
@ -38,7 +35,7 @@ public class UITabGroup extends UIButtonGroup<Integer> {
} else if (number == BUTTON_NUMBER || number == SEVEN_NUMBER) {
return new FiveButtonLayout(2);
} else {
return new GridLayout(2, 3, 1, 1);
return new GridLayout(2, 3, 0, 0);
}
}
@ -54,14 +51,6 @@ public class UITabGroup extends UIButtonGroup<Integer> {
this.isDrawLine = isDrawLine;
}
@Override
protected Border getGroupBorder() {
if (!isDrawLine) {
return BorderFactory.createEmptyBorder(0, 0, 0, 0);
}
return BorderFactory.createEmptyBorder(1, GAP, 1, GAP);
}
@Override
public void setSelectedIndex(int newSelectedIndex, boolean fireChanged) {
super.setSelectedIndex(newSelectedIndex, false);

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

@ -1,7 +1,7 @@
package com.fr.design.mainframe;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.PropertiesItemUI;
import com.fine.theme.light.ui.RectangleButtonUI;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.ui.FlatLineBorder;
import com.fr.base.FRContext;
@ -1004,7 +1004,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
};
button.setDisabledIcon(new LazyIcon(btnIconName + ICON_SUFFIX_DISABLED));
button.set4LargeToolbarButton();
button.setUI(new PropertiesItemUI(false));
button.setUI(new RectangleButtonUI(false));
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {

3
designer-base/src/main/java/com/fr/design/mainframe/theme/edit/cell/CellStyleEditPane.java

@ -4,10 +4,8 @@ import com.fr.base.CellBorderStyle;
import com.fr.base.Style;
import com.fr.base.theme.settings.ThemedCellStyle;
import com.fr.design.cell.CellRectangleStylePreviewPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
@ -46,7 +44,6 @@ public class CellStyleEditPane extends MultiTabPane<ThemedCellStyle> {
super();
tabPane.setOneLineTab(true);
tabPane.setDrawLine(false);
tabPane.setBorder(BorderFactory.createLineBorder(UIConstants.SHADOW_GREY));
tabPane.setLayout(new GridLayout(1, 3, 0, 0));
}

2
designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotUITabGroup.java

@ -53,7 +53,7 @@ public class VanChartCustomPlotUITabGroup extends UITabGroup{
}
@Override
protected void initButton(UIToggleButton labelButton) {
protected void initButton(UIToggleButton labelButton, int buttonIndex) {
int ButtonWidth = WIDTH / 3;
if (listNum <= 1){

46
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java

@ -4,14 +4,12 @@ import com.fr.base.CellBorderStyle;
import com.fr.base.NameStyle;
import com.fr.base.Style;
import com.fr.design.actions.utils.ReportActionUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.MultiTabPane;
import com.fr.design.gui.style.*;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.style.BorderUtils;
import javax.swing.*;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.util.ArrayList;
@ -38,7 +36,6 @@ public class CustomStylePane extends MultiTabPane<Style> {
super();
tabPane.setOneLineTab(true);
tabPane.setDrawLine(false);
tabPane.setBorder(BorderFactory.createLineBorder(UIConstants.SHADOW_GREY));
tabPane.setLayout(new GridLayout(1, 3, 0, 0));
}
@ -54,16 +51,18 @@ public class CustomStylePane extends MultiTabPane<Style> {
}
/**
* @return
* 获取面板标题
*
* @return 面板标题
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Style");
}
/**
* for ScrollBar
* for ScrollBar添加监听
*
* @param l
* @param l 监听器
*/
public void addTabChangeListener(ChangeListener l) {
if (tabPane != null) {
@ -74,34 +73,27 @@ public class CustomStylePane extends MultiTabPane<Style> {
}
}
/**
*
*/
public void reset() {
populateBean(null);
}
@Override
/**
*
*/
public void populateBean(Style ob) {
for (int i = 0; i < paneList.size(); i++) {
((AbstractBasicStylePane) paneList.get(i)).populateBean(ob);
for (BasicPane basicPane : paneList) {
((AbstractBasicStylePane) basicPane).populateBean(ob);
}
}
@Override
/**
*
*/
public Style updateBean() {
return updateStyle(ReportActionUtils.getCurrentStyle(reportPane));
}
/**
* @param style
* @return
* 更新面板样式
*
* @param style 样式
* @return 更新后的样式
*/
public Style updateStyle(Style style) {
return ((AbstractBasicStylePane) paneList.get(tabPane.getSelectedIndex())).update(style);//只更新当前选中面板的样式
@ -136,7 +128,9 @@ public class CustomStylePane extends MultiTabPane<Style> {
}
/**
* @param ePane
* 处理边框
*
* @param ePane 面板
*/
public void dealWithBorder(ElementCasePane ePane) {
this.reportPane = ePane;
@ -148,8 +142,8 @@ public class CustomStylePane extends MultiTabPane<Style> {
}
/**
* @param ob
* @return
* @param ob 目标对象
* @return 判断是否需处理
*/
public boolean accept(Object ob) {
return ob instanceof Style && !(ob instanceof NameStyle);
@ -157,20 +151,14 @@ public class CustomStylePane extends MultiTabPane<Style> {
@Override
protected List<BasicPane> initPaneList() {
paneList = new ArrayList<BasicPane>();
paneList = new ArrayList<>();
paneList.add(new TextFontTippedPane(true));
paneList.add(new BorderPane());
paneList.add(new AlignmentPane());
// paneList.add(new FRFontPane());
// paneList.add(backgroundPane = new BackgroundPane());
return paneList;
}
@Override
/**
*
*/
public void updateBean(Style ob) {
return;
}
}

4
designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java

@ -99,10 +99,10 @@ public class ReportColumnsPane extends BasicPane{
onOffButtonGroup = new UIButtonGroup(textArray) {
@Override
protected void initButton(UIToggleButton labelButton) {
protected void initButton(UIToggleButton labelButton, int index) {
labelButton.setSize(new Dimension(60,20));
labelButton.setPreferredSize(new Dimension(60, 20));
super.initButton(labelButton);
super.initButton(labelButton, index);
}
};
onOffButtonGroup.addActionListener(onOffListener);

Loading…
Cancel
Save