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 752681ef0..624e2e8ee 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 @@ -26,6 +26,9 @@ import java.util.List; public class UIButtonGroup extends JPanel implements GlobalNameObserver { private static final long serialVersionUID = 1L; + private static final int TEXT_LENGTH = 3; + private static final int BUTTON_SIZE = 2; + private int currentButtonSize = 0; protected List labelButtonList; protected int selectedIndex = -1; private List objectList;// 起到一个render的作用 @@ -154,6 +157,7 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { if (!ArrayUtils.isEmpty(objects) && textArray.length == objects.length) { this.objectList = Arrays.asList(objects); } + currentButtonSize = textArray.length; labelButtonList = new ArrayList(textArray.length); this.setLayout(getGridLayout(textArray.length)); this.setBorder(getGroupBorder()); @@ -214,11 +218,20 @@ public class UIButtonGroup extends JPanel implements GlobalNameObserver { protected void initButton(UIToggleButton labelButton) { labelButton.setBorderPainted(false); + adjustButton(labelButton); UIComponentUtils.setLineWrap(labelButton); labelButtonList.add(labelButton); this.add(labelButton); } + private void adjustButton(UIToggleButton labelButton) { + if (labelButton.getText().length() > TEXT_LENGTH && currentButtonSize > BUTTON_SIZE) { + Dimension dimension = labelButton.getPreferredSize(); + dimension.height <<= 1; + labelButton.setPreferredSize(dimension); + } + } + protected Border getGroupBorder() { return BorderFactory.createEmptyBorder(1, 1, 1, 1); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java index 0fdd61f92..39d0b8f1b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java @@ -4,7 +4,6 @@ package com.fr.van.chart.designer.style; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.plugin.chart.range.VanChartRangeLegend; import com.fr.plugin.chart.type.LegendType; @@ -53,6 +52,7 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { gradualLegendPane.setParentPane(parent); //区域段图例面板 sectionLegendPane = createSectionLegendPane(); + sectionLegendPane.setParentPane(parent); JPanel panel = new JPanel(new CardLayout()){ @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionLegendPane.java index 0265a4f73..828f40d73 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionLegendPane.java @@ -4,9 +4,9 @@ import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; - import com.fr.plugin.chart.range.SectionLegend; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -24,6 +24,10 @@ public class SectionLegendPane extends JPanel{ initComponents(); } + public void setParentPane(VanChartStylePane parent){ + labelFormPane.setParentPane(parent); + } + private void initComponents() { intervalConfigPane = createSectionIntervalConfigPane(this.parent); JPanel intervalConfigPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Section_Config"), intervalConfigPane);