Browse Source

CHART-14181 设计器空数据提示面板

feature/big-screen
白岳 5 years ago
parent
commit
36f6037b21
  1. 92
      designer-chart/src/main/java/com/fr/design/module/ChartEmptyDataStylePane.java

92
designer-chart/src/main/java/com/fr/design/module/ChartEmptyDataStylePane.java

@ -2,11 +2,13 @@ package com.fr.design.module;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ChartEmptyDataStyleConf; import com.fr.base.ChartEmptyDataStyleConf;
import com.fr.base.Style;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.background.image.ImagePreviewPane; import com.fr.design.style.background.image.ImagePreviewPane;
@ -14,7 +16,7 @@ import com.fr.design.utils.ImageUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper; import com.fr.stable.CoreGraphHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -24,6 +26,7 @@ import javax.swing.JFileChooser;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import java.io.File;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
@ -32,7 +35,6 @@ import java.awt.GridLayout;
import java.awt.Image; import java.awt.Image;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.File;
/** /**
* Created by mengao on 2017/11/23. * Created by mengao on 2017/11/23.
@ -47,8 +49,10 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private UIButtonGroup emptyData; private UIButtonGroup emptyData;
private UILabel imageContent;
private UIButtonGroup imageData;
private UIRadioButton defaultRadioButton; private UIRadioButton defaultRadioButton;
private UIRadioButton customRadioButton; private UIRadioButton adjustRadioButton;
private UIButton selectPictureButton; private UIButton selectPictureButton;
private ImagePreviewPane previewPane; private ImagePreviewPane previewPane;
@ -72,7 +76,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
} }
private JPanel creatNorthPane() { private JPanel creatNorthPane() {
emptyData = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); emptyData = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")});
emptyData.setSelectedIndex(0); emptyData.setSelectedIndex(0);
emptyData.setPreferredSize(new Dimension(WIDTH, HEIGHT)); emptyData.setPreferredSize(new Dimension(WIDTH, HEIGHT));
emptyData.addActionListener(new ActionListener() { emptyData.addActionListener(new ActionListener() {
@ -83,8 +87,24 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
} }
}); });
UILabel promptContent = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Tip_Content")); imageData = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), Toolkit.i18nText("Fine-Design_Chart_Mode_Custom")});
JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0); imageData.setSelectedIndex(0);
imageData.setPreferredSize(new Dimension(WIDTH, HEIGHT));
imageData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
emptyDataImage = null;
checkIsCustom();
repaintPreviewPane();
}
});
UILabel promptContent = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Tip_Content"));
imageContent = new UILabel(Toolkit.i18nText("Fine-Design_Report_Image"));
JPanel emptyPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0);
JPanel imagePane = GUICoreUtils.createFlowPane(new Component[]{imageContent, imageData}, FlowLayout.LEFT, TEN, 0);
imagePane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{emptyPane, imagePane}, FlowLayout.LEFT, 0, 0);
northPane.setBorder(BorderFactory.createEmptyBorder(0, FIVE, 0, 0)); northPane.setBorder(BorderFactory.createEmptyBorder(0, FIVE, 0, 0));
return northPane; return northPane;
} }
@ -96,7 +116,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPane.add(previewContainerPane, BorderLayout.CENTER); centerPane.add(previewContainerPane, BorderLayout.CENTER);
JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Preview"));
previewOwnerPane.setLayout(new BorderLayout()); previewOwnerPane.setLayout(new BorderLayout());
previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER);
previewContainerPane.add(initSelectFilePane(), BorderLayout.EAST); previewContainerPane.add(initSelectFilePane(), BorderLayout.EAST);
@ -116,25 +136,27 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
selectFilePane.setBorder(BorderFactory.createEmptyBorder(TEN, FIVE, 0, THIRTY)); selectFilePane.setBorder(BorderFactory.createEmptyBorder(TEN, FIVE, 0, THIRTY));
defaultRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default")); defaultRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Default"));
customRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Custom")); adjustRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Image_Adjust"));
ButtonGroup buttonGroup = new ButtonGroup(); ButtonGroup buttonGroup = new ButtonGroup();
defaultRadioButton.setSelected(true); defaultRadioButton.setSelected(true);
buttonGroup.add(defaultRadioButton); buttonGroup.add(defaultRadioButton);
buttonGroup.add(customRadioButton); buttonGroup.add(adjustRadioButton);
defaultRadioButton.setEnabled(false);
adjustRadioButton.setEnabled(false);
defaultRadioButton.addActionListener(getLayoutActionListener()); defaultRadioButton.addActionListener(getLayoutActionListener());
customRadioButton.addActionListener(getLayoutActionListener()); adjustRadioButton.addActionListener(getLayoutActionListener());
JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN));
jp.add(defaultRadioButton);
jp.add(customRadioButton);
selectPictureButton = new UIButton( selectPictureButton = new UIButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select")); Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select"));
selectPictureButton.setEnabled(false);
selectPictureButton.addActionListener(getSelectPictureActionListener()); selectPictureButton.addActionListener(getSelectPictureActionListener());
jp.add(selectPictureButton);
JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN));
jp.add(selectPictureButton);
jp.add(defaultRadioButton);
jp.add(adjustRadioButton);
selectFilePane.add(jp, BorderLayout.NORTH); selectFilePane.add(jp, BorderLayout.NORTH);
return selectFilePane; return selectFilePane;
@ -142,10 +164,8 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private ActionListener getLayoutActionListener() { private ActionListener getLayoutActionListener() {
return new ActionListener() { return new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
emptyDataImage = null; setImageStyle();
checkCustomImage();
repaintPreviewPane(); repaintPreviewPane();
} }
}; };
@ -188,17 +208,30 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private void checkEmptyDataStyle() { private void checkEmptyDataStyle() {
boolean b = emptyData.getSelectedIndex() == 0; boolean b = emptyData.getSelectedIndex() == 0;
defaultRadioButton.setVisible(b);
adjustRadioButton.setVisible(b);
selectPictureButton.setVisible(b);
imageContent.setVisible(b);
imageData.setVisible(b);
}
private void checkIsCustom() {
boolean b = imageData.getSelectedIndex() == 1;
defaultRadioButton.setEnabled(b); defaultRadioButton.setEnabled(b);
customRadioButton.setEnabled(b); adjustRadioButton.setEnabled(b);
selectPictureButton.setEnabled(b); selectPictureButton.setEnabled(b);
} }
private void checkCustomImage() { private void setImageStyle() {
selectPictureButton.setVisible(customRadioButton.isSelected()); if (adjustRadioButton.isSelected()) {
previewPane.setImageStyle(Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST));
} else {
previewPane.setImageStyle(Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER));
}
} }
private void repaintPreviewPane() { private void repaintPreviewPane() {
emptyDataImage = customRadioButton.isSelected() ? emptyDataImage : DEFAULT_EMPTY_DATA_IMAGE; emptyDataImage = imageData.getSelectedIndex() == 1 ? emptyDataImage : DEFAULT_EMPTY_DATA_IMAGE;
previewPane.setImage(emptyData.getSelectedIndex() == 0 ? emptyDataImage : null); previewPane.setImage(emptyData.getSelectedIndex() == 0 ? emptyDataImage : null);
previewPane.repaint(); previewPane.repaint();
} }
@ -215,12 +248,14 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
public void populateBean() { public void populateBean() {
ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance(); ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance();
emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() == true ? 0 : 1); emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() ? 0 : 1);
customRadioButton.setSelected(manager.isCustomEmptyDataStyle()); imageData.setSelectedIndex(manager.isCustomEmptyDataStyle() ? 1 : 0);
adjustRadioButton.setSelected(manager.isAdjust());
emptyDataImage = manager.getEmptyDataImage(); emptyDataImage = manager.getEmptyDataImage();
checkEmptyDataStyle(); checkEmptyDataStyle();
checkCustomImage(); checkIsCustom();
setImageStyle();
repaintPreviewPane(); repaintPreviewPane();
} }
@ -228,7 +263,8 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance(); ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance();
manager.setOpenEmptyDataStyle(emptyData.getSelectedIndex() == 0); manager.setOpenEmptyDataStyle(emptyData.getSelectedIndex() == 0);
manager.setCustomEmptyDataStyle(customRadioButton.isSelected()); manager.setCustomEmptyDataStyle(imageData.getSelectedIndex() == 1);
manager.setAdjust(adjustRadioButton.isSelected());
manager.setEmptyDataImage(emptyDataImage); manager.setEmptyDataImage(emptyDataImage);
} }
} }

Loading…
Cancel
Save