Browse Source

Pull request #7467: REPORT-64445 交互视觉修改

Merge in DESIGN/design from ~KERRY/design_10.0:feature/x to feature/x

* commit 'dbb0201f46aa7b1f10f8a8b7c9d74ffbddde71db':
  REPORT-64445 交互视觉修改
feature/x
kerry 3 years ago
parent
commit
913c7a6b65
  1. 106
      designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java
  2. 12
      designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java
  3. 2
      designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java
  4. 3
      designer-base/src/main/resources/com/fr/design/icon/icon_ec_default_fit.svg

106
designer-base/src/main/java/com/fr/design/report/fit/FormFitConfigPane.java

@ -1,17 +1,35 @@
package com.fr.design.report.fit;
import com.fr.base.svg.SVGLoader;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.report.fit.menupane.FitRadioGroup;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class FormFitConfigPane extends ReportFitConfigPane {
private static final int ICON_OFFSET_X = 25;
private static final int ICON_OFFSET_Y = 3;
private static final int ICON_SIZE = 16;
private static final Image HOVER_IMAGE = SVGLoader.load("/com/fr/design/icon/icon_ec_default_fit.svg");
private static final int DEFAULT_ITEM = 0;
private static final int CUSTOM_ITEM = 1;
public FormFitConfigPane(FitAttrModel fitAttrModel) {
@ -33,6 +51,92 @@ public class FormFitConfigPane extends ReportFitConfigPane {
return jPanel;
}
protected void initRadioGroup(FitRadioGroup fitRadioGroup, String name, String[] options, Component[] components) {
components[0] = new UILabel(name);
for (int i = 0; i < options.length; i++) {
if (options[i] != null) {
UIRadioButton fontFitRadio = ComparatorUtils.equals(options[i], Toolkit.i18nText("Fine-Designer_Fit-Default")) ? new UIRadioButtonWithIcon(options[i]) : new UIRadioButton(options[i]);
fitRadioGroup.add(fontFitRadio);
components[i + 1] = fontFitRadio;
} else {
components[i + 1] = null;
}
}
fitRadioGroup.addActionListener(getPreviewActionListener());
}
private class UIRadioButtonWithIcon extends UIRadioButton {
private final JPopupMenu popupMenu;
private NewFitPreviewPane ecFitPreviewPane;
public UIRadioButtonWithIcon(String text) {
super(text);
popupMenu = this.createPopupMenu();
initMouseListener();
}
private JPopupMenu createPopupMenu() {
UIPopupMenu uiPopupMenu = new UIPopupMenu() {
@Override
protected void paintBorder(Graphics g) {
}
};
uiPopupMenu.setLayout(new BorderLayout(0, 0));
uiPopupMenu.setOpaque(false);
uiPopupMenu.add(ecFitPreviewPane = new NewFitPreviewPane(FitType.HORIZONTAL_FIT), BorderLayout.CENTER);
ecFitPreviewPane.setPreferredSize(new Dimension(300, 204));
return uiPopupMenu;
}
private void initMouseListener() {
this.addMouseListener(new MouseAdapter() {
@Override
public void mouseExited(MouseEvent e) {
super.mouseExited(e);
hidePreviewPane();
}
});
int defaultTextWidth = calculateStartX();
this.addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
super.mouseMoved(e);
if (new Rectangle(ICON_OFFSET_X + defaultTextWidth, ICON_OFFSET_Y, ICON_SIZE, ICON_SIZE).contains(e.getPoint())) {
showPreviewPane(e);
} else {
hidePreviewPane();
}
}
});
}
public void showPreviewPane(MouseEvent e) {
popupMenu.setVisible(true);
ecFitPreviewPane.refreshPreview(fontRadioGroup.isFontFit());
GUICoreUtils.showPopupMenu(popupMenu, this, e.getX() + 10, e.getY() + 10);
}
public void hidePreviewPane() {
if (popupMenu != null && popupMenu.isVisible()) {
popupMenu.setVisible(false);
}
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(HOVER_IMAGE, calculateStartX() + ICON_OFFSET_X, ICON_OFFSET_Y, null);
}
private int calculateStartX() {
FontMetrics metrics = this.getFontMetrics(this.getFont());
return metrics.stringWidth(this.getText());
}
}
private JPanel createTipPane() {
JPanel jPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
UILabel label1 = new UILabel(Toolkit.i18nText("Fine-Design_Form_PC_FIT_Config_Tip1"));

12
designer-base/src/main/java/com/fr/design/report/fit/NewFitPreviewPane.java

@ -16,8 +16,16 @@ public class NewFitPreviewPane extends JPanel {
private FitType fitType = FitType.DOUBLE_FIT;
private static final Color DEFAULT_PAINT_COLOR = Color.decode("#419BF9");
private static final int FIT_FONT_SIZE = 15;
private static final int NO_FIT_FONT_SIZE = 9;
private static final Dimension NO_FIT_CONTAINER_DIMENSION = new Dimension(200, 136);
private static final int NO_FIT_FONT_SIZE = 10;
private static final Dimension NO_FIT_CONTAINER_DIMENSION = new Dimension(230, 80);
public NewFitPreviewPane(){
}
public NewFitPreviewPane(FitType fitType){
this.fitType = fitType;
}
@Override
public void paint(Graphics g) {

2
designer-base/src/main/java/com/fr/design/report/fit/ReportFitConfigPane.java

@ -93,7 +93,7 @@ public class ReportFitConfigPane extends JPanel {
fitRadioGroup.addActionListener(getPreviewActionListener());
}
private ActionListener getPreviewActionListener() {
protected ActionListener getPreviewActionListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {

3
designer-base/src/main/resources/com/fr/design/icon/icon_ec_default_fit.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1 8C1 11.866 4.13401 15 8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8ZM14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8ZM7.25314 7.19772C7.25314 6.7835 7.58893 6.44772 8.00314 6.44772C8.41735 6.44772 8.75314 6.7835 8.75314 7.19772V11.25C8.75314 11.6642 8.41735 12 8.00314 12C7.58893 12 7.25314 11.6642 7.25314 11.25V7.19772ZM8.00314 4C7.58893 4 7.25314 4.33579 7.25314 4.75C7.25314 5.16421 7.58893 5.5 8.00314 5.5C8.41735 5.5 8.75314 5.16421 8.75314 4.75C8.75314 4.33579 8.41735 4 8.00314 4Z" fill="#2F8EF1"/>
</svg>

After

Width:  |  Height:  |  Size: 753 B

Loading…
Cancel
Save