From 3e213834d48feac56230a74e9bb9e4c1d6f29e0f Mon Sep 17 00:00:00 2001 From: plough Date: Tue, 15 Jan 2019 16:00:29 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-14057=2010.0=E6=97=A5=E6=96=87=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=3D>53=20?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8=3D>=E6=A0=B7=E5=BC=8F=3D>=E7=B3=BB=E5=88=97?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/ibutton/UIButtonGroup.java | 2 + .../fr/design/utils/gui/UIComponentUtils.java | 5 ++- .../com/fr/design/widget/FRWidgetFactory.java | 38 +++++++++++++++++++ .../column/VanChartColumnSeriesPane.java | 5 ++- .../designer/TableLayout4VanChartHelper.java | 4 +- .../component/VanChartLineTypePane.java | 7 +++- .../component/VanChartTrendLinePane.java | 7 +++- .../component/border/VanChartBorderPane.java | 10 ++++- .../border/VanChartBorderWithAlphaPane.java | 7 +++- .../border/VanChartBorderWithRadiusPane.java | 7 +++- 10 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/widget/FRWidgetFactory.java diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java index 59ad63de60..752681ef0c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java @@ -3,6 +3,7 @@ package com.fr.design.gui.ibutton; import com.fr.design.constants.UIConstants; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; +import com.fr.design.utils.gui.UIComponentUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import sun.swing.SwingUtilities2; @@ -213,6 +214,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { protected void initButton(UIToggleButton labelButton) { labelButton.setBorderPainted(false); + UIComponentUtils.setLineWrap(labelButton); labelButtonList.add(labelButton); this.add(labelButton); } diff --git a/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java index 2f60567248..3e1f98555f 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java @@ -7,6 +7,7 @@ import com.fr.stable.StringUtils; import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Component; import java.awt.Dimension; /** @@ -61,7 +62,7 @@ public class UIComponentUtils { * @param layoutConstraint,添加的方向,如 BorderLayout.NORTH * @return 包装好的 JPanel */ - public static JPanel wrapWithBorderLayoutPane(JComponent comp, String layoutConstraint) { + public static JPanel wrapWithBorderLayoutPane(Component comp, String layoutConstraint) { JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); panel.add(comp, layoutConstraint); return panel; @@ -72,7 +73,7 @@ public class UIComponentUtils { * @param comp,待包装的组件 * @return 包装好的 JPanel(布局方向为 BorderLayout.NORTH) */ - public static JPanel wrapWithBorderLayoutPane(JComponent comp) { + public static JPanel wrapWithBorderLayoutPane(Component comp) { return wrapWithBorderLayoutPane(comp, BorderLayout.NORTH); } diff --git a/designer-base/src/main/java/com/fr/design/widget/FRWidgetFactory.java b/designer-base/src/main/java/com/fr/design/widget/FRWidgetFactory.java new file mode 100644 index 0000000000..5770ed5e8a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/widget/FRWidgetFactory.java @@ -0,0 +1,38 @@ +package com.fr.design.widget; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.utils.gui.UIComponentUtils; + +/** + * 创建 widget 的静态工厂 + * Created by plough on 2019/1/15. + */ +public class FRWidgetFactory { + // 不可实例化 + private FRWidgetFactory() { + throw new AssertionError(); + } + + /** + * 创建一个可换行的 UILabel + * @param text 标签文字 + * @return com.fr.design.gui.ilable.UILabel + */ + public static UILabel createLineWrapLabel(String text) { + UILabel label = new UILabel(text); + UIComponentUtils.setLineWrap(label); + return label; + } + + /** + * 创建一个可换行的 UILabel + * @param text 标签文字 + * @param lineWidth 最大行宽 + * @return com.fr.design.gui.ilable.UILabel + */ + public static UILabel createLineWrapLabel(String text, int lineWidth) { + UILabel label = new UILabel(text); + UIComponentUtils.setLineWrap(label, lineWidth); + return label; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java index a71babe8f9..aeaa64d928 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java @@ -12,6 +12,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.backgroundpane.ImageBackgroundQuickPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; +import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.base.AttrSeriesImageBackground; import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.stable.Constants; @@ -91,8 +92,10 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane { }; JPanel panel2 = TableLayout4VanChartHelper.createGapTableLayoutPane(components2, row, col); + UILabel fillImageLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image")); + UIComponentUtils.setLineWrap(fillImageLabel); Component[][] components3 = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Filled_With_Image")),isFillWithImage}, + new Component[]{fillImageLabel, UIComponentUtils.wrapWithBorderLayoutPane(isFillWithImage)}, }; JPanel panel3 = TableLayout4VanChartHelper.createGapTableLayoutPane(components3, row, col); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/TableLayout4VanChartHelper.java b/designer-chart/src/main/java/com/fr/van/chart/designer/TableLayout4VanChartHelper.java index da918bb792..4ea76b32ef 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/TableLayout4VanChartHelper.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/TableLayout4VanChartHelper.java @@ -5,6 +5,7 @@ import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.UIComponentUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -59,9 +60,10 @@ public class TableLayout4VanChartHelper { double[] rowSize = {p, p}; UILabel label = new UILabel(title); label.setVerticalAlignment(SwingConstants.TOP); + UIComponentUtils.setLineWrap(label); Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{label, component}, + new Component[]{label, UIComponentUtils.wrapWithBorderLayoutPane(component)}, }; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, COMPONENT_INTERVAL, LayoutConstants.VGAP_LARGE); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java index 012677304a..78f93162f8 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java @@ -6,6 +6,8 @@ import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.type.LineStyle; import com.fr.stable.Constants; @@ -52,7 +54,10 @@ public class VanChartLineTypePane extends BasicPane { Component[][] components = new Component[][]{ new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")),lineWidth}, + new Component[]{ + FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), + UIComponentUtils.wrapWithBorderLayoutPane(lineWidth) + }, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present")),lineStyle}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Null_Value_Break")),nullValueBreak}, }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java index ca28a6624c..134598bd71 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java @@ -13,6 +13,8 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.base.TrendLineType; import com.fr.plugin.chart.base.VanChartAttrTrendLine; import com.fr.plugin.chart.base.VanChartConstants; @@ -65,7 +67,10 @@ public class VanChartTrendLinePane extends BasicPane{ Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), trendLineStyle}, + new Component[]{ + FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), + UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle) + }, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType}, new Component[]{label, periodPane} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPane.java index c90fef0a41..8d9bf55d41 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderPane.java @@ -9,6 +9,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.utils.gui.UIComponentUtils; import com.fr.stable.CoreConstants; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -41,10 +42,15 @@ public class VanChartBorderPane extends BasicPane { } protected Component[][] getUseComponent() { + UILabel lineStyleLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")); + UIComponentUtils.setLineWrap(lineStyleLabel); + UILabel colorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")); + UIComponentUtils.setLineWrap(colorLabel); + return new Component[][]{ new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")),currentLineCombo}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),currentLineColorPane}, + new Component[]{lineStyleLabel, currentLineCombo}, + new Component[]{colorLabel, currentLineColorPane}, }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithAlphaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithAlphaPane.java index d185f735a1..e2ff67c911 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithAlphaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithAlphaPane.java @@ -3,6 +3,8 @@ package com.fr.van.chart.designer.component.border; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.base.AttrBorderWithAlpha; @@ -29,7 +31,10 @@ public class VanChartBorderWithAlphaPane extends VanChartBorderPane{ protected Component[][] getUseComponent() { return new Component[][]{ new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")),currentLineCombo}, + new Component[]{ + FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), + UIComponentUtils.wrapWithBorderLayoutPane(currentLineCombo) + }, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),currentLineColorPane}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent} }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithRadiusPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithRadiusPane.java index f23e0f01ec..63eff90477 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithRadiusPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/border/VanChartBorderWithRadiusPane.java @@ -4,6 +4,8 @@ import com.fr.chart.base.AttrBorder; import com.fr.chart.chartglyph.GeneralInfo; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.utils.gui.UIComponentUtils; +import com.fr.design.widget.FRWidgetFactory; import javax.swing.JSeparator; @@ -28,7 +30,10 @@ public class VanChartBorderWithRadiusPane extends VanChartBorderPane { protected Component[][] getUseComponent() { return new Component[][]{ new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")),currentLineCombo}, + new Component[]{ + FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")), + UIComponentUtils.wrapWithBorderLayoutPane(currentLineCombo) + }, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),currentLineColorPane}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")),radius} } ;