Browse Source

Pull request #4369: CHART-18965 自定义html框优化

Merge in DESIGN/design from ~BJORN/design:feature/10.0 to feature/10.0

* commit 'ab113ab438b6b8044e81416d7d292e5d7c608225':
  CHART-18965 自定义html框优化
feature/10.0
Bjorn 4 years ago
parent
commit
9893b4430f
  1. 29
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPane.java
  2. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithOutWidthAndHeight.java

29
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPane.java

@ -11,9 +11,9 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.VanChartStylePane;
@ -47,6 +47,8 @@ public class VanChartHtmlLabelPane extends JPanel{
private VanChartStylePane parent; private VanChartStylePane parent;
private JPanel widthAndHeightPane;
public void setCustomFormatterText(String text) { public void setCustomFormatterText(String text) {
contentTextArea.setText(text); contentTextArea.setText(text);
} }
@ -56,24 +58,28 @@ public class VanChartHtmlLabelPane extends JPanel{
} }
public VanChartHtmlLabelPane() { public VanChartHtmlLabelPane() {
useHtml = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Html")); useHtml = new UIToggleButton(Toolkit.i18nText("Fine-Design_Chart_Html"));
UIComponentUtils.setLineWrap(useHtml); UIComponentUtils.setLineWrap(useHtml);
JPanel widthAndHeightPane = createWidthAndHeightPane(); useHtml.addChangeListener(e -> checkWidthAndHeightPane());
widthAndHeightPane = createWidthAndHeightPane();
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {f}; double[] columnSize = {f};
double[] rowSize = {p, p, p}; double[] rowSize = {p, p, p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createJSContentPane()}, new Component[]{createJSContentPane()},
new Component[]{useHtml}, new Component[]{useHtml},
new Component[]{widthAndHeightPane} new Component[]{null, null},
}; };
JPanel contentPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel contentPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(contentPane, BorderLayout.CENTER); this.add(contentPane, BorderLayout.NORTH);
if (widthAndHeightPane != null) {
this.add(widthAndHeightPane, BorderLayout.CENTER);
}
} }
private JComponent createJSContentPane() { private JComponent createJSContentPane() {
@ -127,9 +133,9 @@ public class VanChartHtmlLabelPane extends JPanel{
} }
protected JPanel createWidthAndHeightPane() { protected JPanel createWidthAndHeightPane() {
isCustomWidth = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Width")); isCustomWidth = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Custom_Width"));
customWidth = new UITextField(6); customWidth = new UITextField(6);
isCustomHeight = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Height")); isCustomHeight = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Custom_Height"));
customHeight = new UITextField(6); customHeight = new UITextField(6);
isCustomWidth.addActionListener(new ActionListener() { isCustomWidth.addActionListener(new ActionListener() {
@ -171,6 +177,12 @@ public class VanChartHtmlLabelPane extends JPanel{
checkWidth(); checkWidth();
} }
private void checkWidthAndHeightPane() {
if (widthAndHeightPane != null) {
widthAndHeightPane.setVisible(useHtml.isSelected());
}
}
public void populate(VanChartHtmlLabel htmlLabel) { public void populate(VanChartHtmlLabel htmlLabel) {
if (htmlLabel == null) { if (htmlLabel == null) {
return; return;
@ -186,6 +198,7 @@ public class VanChartHtmlLabelPane extends JPanel{
isCustomHeight.setSelected(htmlLabel.isCustomHeight()); isCustomHeight.setSelected(htmlLabel.isCustomHeight());
customHeight.setText(htmlLabel.getHeight()); customHeight.setText(htmlLabel.getHeight());
checkBoxUse(); checkBoxUse();
checkWidthAndHeightPane();
} }
public void update(VanChartHtmlLabel htmlLabel) { public void update(VanChartHtmlLabel htmlLabel) {

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

@ -12,7 +12,7 @@ public class VanChartHtmlLabelPaneWithOutWidthAndHeight extends VanChartHtmlLabe
private static final long serialVersionUID = -9213286452724939880L; private static final long serialVersionUID = -9213286452724939880L;
protected JPanel createWidthAndHeightPane() { protected JPanel createWidthAndHeightPane() {
return new JPanel(); return null;
} }
protected void populateWidthAndHeight(VanChartHtmlLabel htmlLabel) { protected void populateWidthAndHeight(VanChartHtmlLabel htmlLabel) {

Loading…
Cancel
Save