帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
4.0 KiB

package com.fr.design.condition;
import com.fine.theme.utils.FineUIScale;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.base.CellBorderStyle;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.style.BorderPane;
import com.fr.report.cell.cellattr.highlight.BorderHighlightAction;
import com.fr.report.cell.cellattr.highlight.HighlightAction;
import com.fr.stable.Constants;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.row;
/**
* @author richie
* @date 2015-03-26
* @since 8.0
*/
public class BorderHighlightPane extends ConditionAttrSingleConditionPane<HighlightAction> {
private CellBorderStyle border;
private UIButton borderButton;
public BorderHighlightPane(final ConditionAttributesPane conditionAttributesPane) {
super(conditionAttributesPane);
borderButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")) {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g.create();
if (border == null) {
return;
}
if (border.getTopStyle() == 1) {
g2d.setColor(border.getTopColor());
g2d.drawLine(4, 4, getWidth() - 4, 4);
}
if (border.getLeftStyle() == 1) {
g2d.setColor(border.getLeftColor());
g2d.drawLine(4, 4, 4, getHeight() - 4);
}
if (border.getBottomStyle() == 1) {
g2d.setColor(border.getBottomColor());
g2d.drawLine(4, getHeight() - 4, getWidth() - 4, getHeight() - 4);
}
if (border.getRightStyle() == 1) {
g2d.setColor(border.getRightColor());
g2d.drawLine(getWidth() - 4, getHeight() - 4, getWidth() - 4, 4);
}
}
};
borderButton.setPreferredSize(FineUIScale.scale(new Dimension(53, 23)));
borderButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final BorderPane borderPane = new BorderPane();
int line = border == null ? Constants.LINE_NONE : border.getTopStyle();
Color color = border == null ? Color.black : border.getTopColor();
borderPane.populate(border, false, line, color);
BasicDialog dialog = borderPane.showWindow(SwingUtilities.getWindowAncestor(conditionAttributesPane));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
border = borderPane.update();
borderButton.setBorderStyle(border);
borderButton.repaint();
}
});
dialog.setVisible(true);
}
});
UILabel borderLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"));
this.add(row(10, cell(borderLabel).weight(0.2), row(
10,
cell(borderButton)).weight(0.8)
).with(it -> it.setBorder(new ScaledEmptyBorder(5, 5, 5, 0))).getComponent(), BorderLayout.CENTER);
}
@Override
public String nameForPopupMenuItem() {
7 years ago
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border");
}
public void populate(HighlightAction ha) {
this.border = ((BorderHighlightAction)ha).getCellBorder();
borderButton.setBorderStyle(border);
borderButton.repaint();
}
public HighlightAction update() {
return new BorderHighlightAction(border);
}
}