diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java new file mode 100644 index 000000000..f9c9f7d49 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java @@ -0,0 +1,27 @@ +package com.fr.van.chart.designer.component; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.JPanel; +import java.awt.Component; + +public class VanChartHtmlLabelPaneWithBackGroundLabel extends VanChartHtmlLabelPane { + + protected JPanel createWidthAndHeightPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; + + JPanel panel = super.createWidthAndHeightPane(); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Background")), panel}, + }; + + return TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{d, f}); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java index 8586f2106..7fe05a360 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java @@ -13,6 +13,6 @@ public class VanChartLabelContentPane extends VanChartTooltipContentPane { } protected VanChartHtmlLabelPane createHtmlLabelPane() { - return new VanChartHtmlLabelPane(); + return new VanChartHtmlLabelPaneWithBackGroundLabel(); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java deleted file mode 100644 index dafaef060..000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java +++ /dev/null @@ -1,361 +0,0 @@ -package com.fr.van.chart.designer.component; - -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; -import com.fr.plugin.chart.base.AttrTooltipContent; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; -import com.fr.van.chart.designer.style.VanChartStylePane; - -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -public class VanChartLabelContentPaneWithoutRichText extends BasicBeanPane { - - private UIButtonGroup content; - - private ValueFormatPaneWithCheckBox valueFormatPane; - private PercentFormatPaneWithCheckBox percentFormatPane; - private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; - private SeriesNameFormatPaneWithCheckBox seriesNameFormatPane; - - //监控刷新时,自动数据点提示使用 - private ChangedValueFormatPaneWithCheckBox changedValueFormatPane; - private ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane; - private UIButtonGroup styleButton; - private ChartTextAttrPane textAttrPane; - private JPanel centerPane; - private JPanel commonPanel; - private JPanel stylePanel; - private VanChartHtmlLabelPane htmlLabelPane; - - private VanChartStylePane parent; - private JPanel showOnPane; - - public VanChartLabelContentPaneWithoutRichText(VanChartStylePane parent, JPanel showOnPane) { - this.parent = parent; - this.showOnPane = showOnPane; - - this.setLayout(new BorderLayout()); - this.add(createLabelContentPane(), BorderLayout.CENTER); - } - - public ValueFormatPaneWithCheckBox getValueFormatPane() { - return valueFormatPane; - } - - public void setValueFormatPane(ValueFormatPaneWithCheckBox valueFormatPane) { - this.valueFormatPane = valueFormatPane; - } - - public PercentFormatPaneWithCheckBox getPercentFormatPane() { - return percentFormatPane; - } - - public void setPercentFormatPane(PercentFormatPaneWithCheckBox percentFormatPane) { - this.percentFormatPane = percentFormatPane; - } - - public CategoryNameFormatPaneWithCheckBox getCategoryNameFormatPane() { - return categoryNameFormatPane; - } - - public void setCategoryNameFormatPane(CategoryNameFormatPaneWithCheckBox categoryNameFormatPane) { - this.categoryNameFormatPane = categoryNameFormatPane; - } - - public SeriesNameFormatPaneWithCheckBox getSeriesNameFormatPane() { - return seriesNameFormatPane; - } - - public void setSeriesNameFormatPane(SeriesNameFormatPaneWithCheckBox seriesNameFormatPane) { - this.seriesNameFormatPane = seriesNameFormatPane; - } - - private JPanel createLabelContentPane() { - content = new UIButtonGroup<>(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Common"), - Toolkit.i18nText("Fine-Design_Chart_Custom") - }); - - initFormatPane(parent, showOnPane); - - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - - commonPanel = createCommonPanel(); - htmlLabelPane = createHtmlLabelPane(); - htmlLabelPane.setParent(parent); - stylePanel = createTextStylePane(); - centerPane = new JPanel(new CardLayout()) { - @Override - public Dimension getPreferredSize() { - if (content.getSelectedIndex() == 0) { - return commonPanel.getPreferredSize(); - } else { - return new Dimension(commonPanel.getPreferredSize().width, htmlLabelPane.getPreferredSize().height); - } - } - }; - centerPane.add(htmlLabelPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); - centerPane.add(commonPanel, Toolkit.i18nText("Fine-Design_Chart_Common")); - - double[] column = {f, e}; - double[] row = {p, p, p}; - Component[][] components = new Component[][]{ - new Component[]{null, null}, - new Component[]{new UILabel(getLabelContentTitle()), content}, - new Component[]{null, centerPane}, - }; - initContentListener(); - JPanel paramsPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, column); - - JPanel contentPane = new JPanel(new BorderLayout()); - contentPane.add(paramsPanel, BorderLayout.CENTER); - contentPane.add(stylePanel, BorderLayout.SOUTH); - - return getLabelContentPane(contentPane); - } - - protected boolean hasTextStylePane() { - return true; - } - - private JPanel createTextStylePane() { - styleButton = new UIButtonGroup<>(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Automatic"), - Toolkit.i18nText("Fine-Design_Chart_Custom") - }); - - textAttrPane = new ChartTextAttrPane() { - protected Component[][] getComponents(JPanel buttonPane) { - return new Component[][]{ - new Component[]{null, null}, - new Component[]{null, getFontNameComboBox()}, - new Component[]{null, buttonPane} - }; - } - }; - - JPanel buttonPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), styleButton); - - JPanel stylePanel = new JPanel(new BorderLayout()); - stylePanel.add(buttonPane, BorderLayout.CENTER); - stylePanel.add(textAttrPane, BorderLayout.SOUTH); - - initStyleButtonListener(); - - return stylePanel; - } - - private void initStyleButtonListener() { - styleButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - checkStylePane(); - } - }); - } - - private void checkStylePane() { - if (hasTextStylePane()) { - stylePanel.setVisible(true); - textAttrPane.setVisible(styleButton.getSelectedIndex() == 1); - } else { - stylePanel.setVisible(false); - } - } - - protected String getLabelContentTitle() { - return Toolkit.i18nText("Fine-Design_Report_Text"); - } - - protected JPanel getLabelContentPane(JPanel contentPane) { - return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Content"), contentPane); - } - - protected VanChartHtmlLabelPane createHtmlLabelPane() { - return new VanChartHtmlLabelPane(); - } - - protected JPanel createCommonPanel() { - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - - double[] columnSize = {f, p}; - double[] rowSize = getRowSize(p); - - return TableLayoutHelper.createTableLayoutPane(getPaneComponents(), rowSize, columnSize); - } - - protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); - } - - protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); - } - - protected double[] getRowSize(double p) { - return new double[]{p, p, p, p}; - } - - protected Component[][] getPaneComponents() { - return new Component[][]{ - new Component[]{categoryNameFormatPane, null}, - new Component[]{seriesNameFormatPane, null}, - new Component[]{valueFormatPane, null}, - new Component[]{percentFormatPane, null}, - }; - } - - private void initContentListener() { - content.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkCardPane(); - } - }); - } - - - private void checkCardPane() { - CardLayout cardLayout = (CardLayout) centerPane.getLayout(); - if (content.getSelectedIndex() == 1) { - cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); - if (isDirty()) { - setCustomFormatterText(); - setDirty(false); - } - } else { - cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Common")); - } - } - - protected void setCustomFormatterText() { - htmlLabelPane.setCustomFormatterText(updateBean().getFormatterTextFromCommon()); - } - - public boolean isDirty() { - return categoryNameFormatPane.isDirty() || seriesNameFormatPane.isDirty() || valueFormatPane.isDirty() || percentFormatPane.isDirty() - || (changedValueFormatPane != null && changedValueFormatPane.isDirty()) || (changedValueFormatPane != null && changedPercentFormatPane.isDirty()); - } - - public void setDirty(boolean isDirty) { - categoryNameFormatPane.setDirty(isDirty); - seriesNameFormatPane.setDirty(isDirty); - valueFormatPane.setDirty(isDirty); - percentFormatPane.setDirty(isDirty); - - if (changedValueFormatPane != null) { - changedValueFormatPane.setDirty(isDirty); - } - if (changedPercentFormatPane != null) { - changedPercentFormatPane.setDirty(isDirty); - } - } - - @Override - protected String title4PopupWindow() { - return ""; - } - - - @Override - public void populateBean(AttrTooltipContent attrTooltipContent) { - if (attrTooltipContent == null) { - return; - } - - content.setSelectedIndex(attrTooltipContent.isCommon() ? 0 : 1); - - populateFormatPane(attrTooltipContent); - - htmlLabelPane.populate(attrTooltipContent.getHtmlLabel()); - if (!attrTooltipContent.isCommon()) { - setDirty(false); - } - if (hasTextStylePane()) { - this.styleButton.setSelectedIndex(attrTooltipContent.isCustom() ? 1 : 0); - this.textAttrPane.populate(attrTooltipContent.getTextAttr()); - } - checkCardPane(); - checkStylePane(); - } - - protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { - categoryNameFormatPane.populate(attrTooltipContent.getCategoryFormat()); - seriesNameFormatPane.populate(attrTooltipContent.getSeriesFormat()); - valueFormatPane.populate(attrTooltipContent.getValueFormat()); - percentFormatPane.populate(attrTooltipContent.getPercentFormat()); - - if (changedValueFormatPane != null) { - changedValueFormatPane.populate(attrTooltipContent.getChangedValueFormat()); - } - if (changedPercentFormatPane != null) { - changedPercentFormatPane.populate(attrTooltipContent.getChangedPercentFormat()); - } - } - - public AttrTooltipContent updateBean() { - AttrTooltipContent attrTooltipContent = createAttrTooltip(); - - attrTooltipContent.setCommon(content.getSelectedIndex() == 0); - - updateFormatPane(attrTooltipContent); - - updateFormatsWithPaneWidth(attrTooltipContent); - - htmlLabelPane.update(attrTooltipContent.getHtmlLabel()); - - if (hasTextStylePane()) { - attrTooltipContent.setCustom(styleButton.getSelectedIndex() == 1); - attrTooltipContent.setTextAttr(this.textAttrPane.update()); - } - - return attrTooltipContent; - } - - protected AttrTooltipContent createAttrTooltip() { - return new AttrTooltipContent(); - } - - protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { - categoryNameFormatPane.update(attrTooltipContent.getCategoryFormat()); - seriesNameFormatPane.update(attrTooltipContent.getSeriesFormat()); - valueFormatPane.update(attrTooltipContent.getValueFormat()); - percentFormatPane.update(attrTooltipContent.getPercentFormat()); - - if (changedValueFormatPane != null) { - changedValueFormatPane.update(attrTooltipContent.getChangedValueFormat()); - } - if (changedPercentFormatPane != null) { - changedPercentFormatPane.update(attrTooltipContent.getChangedPercentFormat()); - } - } - - private void updateFormatsWithPaneWidth(AttrTooltipContent attrTooltipContent) { - int paneWidth = seriesNameFormatPane.getWidth(); - if (paneWidth == 0) { - attrTooltipContent.getSeriesFormat().setEnable(false); - } - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java index 09e208cc1..7ecb797d6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java @@ -22,6 +22,10 @@ public class VanChartRefreshTooltipContentPane extends VanChartTooltipContentPan return new double[]{p,p,p,p,p,p}; } + protected boolean supportRichEditor() { + return false; + } + @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index fcbe91a5e..523d39a3e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -51,6 +51,15 @@ public class VanChartTooltipContentPane extends BasicBeanPane content; private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; @@ -222,11 +231,19 @@ public class VanChartTooltipContentPane extends BasicBeanPane(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Common"), - Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), - Toolkit.i18nText("Fine-Design_Chart_Custom") - }); + if (supportRichEditor()) { + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + } else { + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + } Component[][] components = new Component[][]{ new Component[]{null, null}, @@ -319,7 +366,12 @@ public class VanChartTooltipContentPane extends BasicBeanPane