Browse Source

删除重复代码

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
e108f4d28b
  1. 44
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java
  2. 11
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java

44
designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java

@ -16,7 +16,7 @@ import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.plugin.chart.attr.VanChartLegend;
import com.fr.plugin.chart.type.ArrangeType; import com.fr.plugin.chart.type.LayoutType;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartFloatPositionPane; import com.fr.van.chart.designer.component.VanChartFloatPositionPane;
@ -54,8 +54,8 @@ public class VanChartPlotLegendPane extends BasicPane {
private VanChartBackgroundWithOutImagePane backgroundPane; private VanChartBackgroundWithOutImagePane backgroundPane;
private UIButtonGroup<Integer> location; private UIButtonGroup<Integer> location;
private UIToggleButton customFloatPositionButton; private UIToggleButton customFloatPositionButton;
private UIButtonGroup<ArrangeType> arrangeButton; private UIButtonGroup<LayoutType> layoutButton;
private JPanel arrangePane; private JPanel layoutPane;
private VanChartFloatPositionPane customFloatPositionPane; private VanChartFloatPositionPane customFloatPositionPane;
//区域显示策略 恢复用注释。下面4行删除。 //区域显示策略 恢复用注释。下面4行删除。
@ -89,10 +89,6 @@ public class VanChartPlotLegendPane extends BasicPane {
return parent; return parent;
} }
public JPanel getArrangePane() {
return arrangePane;
}
public UIButtonGroup<Integer> getLegendLocation() { public UIButtonGroup<Integer> getLegendLocation() {
return location; return location;
} }
@ -207,7 +203,7 @@ public class VanChartPlotLegendPane extends BasicPane {
}; };
customFloatPositionPane = new VanChartFloatPositionPane(); customFloatPositionPane = new VanChartFloatPositionPane();
arrangePane = createArrangePane(); layoutPane = createLayoutPane();
initPositionListener(); initPositionListener();
@ -215,14 +211,15 @@ public class VanChartPlotLegendPane extends BasicPane {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.add(positionPane, BorderLayout.NORTH); panel.add(positionPane, BorderLayout.NORTH);
panel.add(arrangePane, BorderLayout.CENTER); panel.add(layoutPane, BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), panel); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), panel);
} }
private JPanel createArrangePane() { private JPanel createLayoutPane() {
arrangeButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Arrange_Flow"), Toolkit.i18nText("Fine-Design_Chart_Arrange_Aligned")}, layoutButton = new UIButtonGroup<>(
new ArrangeType[]{ArrangeType.FLOW, ArrangeType.ALIGNED}); new String[]{Toolkit.i18nText("Fine-Design_Chart_Layout_Flow"), Toolkit.i18nText("Fine-Design_Chart_Layout_Aligned")},
new LayoutType[]{LayoutType.FLOW, LayoutType.ALIGNED});
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
@ -230,7 +227,7 @@ public class VanChartPlotLegendPane extends BasicPane {
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{null, null}, new Component[]{null, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Arrange")), arrangeButton} new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Arrange")), layoutButton}
}; };
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{f, e}); return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{f, e});
@ -242,7 +239,7 @@ public class VanChartPlotLegendPane extends BasicPane {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
customFloatPositionButton.setSelected(false); customFloatPositionButton.setSelected(false);
checkArrangePaneVisible(); checkLayoutPaneVisible();
checkDisplayStrategyUse(); checkDisplayStrategyUse();
} }
}); });
@ -252,7 +249,7 @@ public class VanChartPlotLegendPane extends BasicPane {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(!customFloatPositionButton.isSelected()){ if(!customFloatPositionButton.isSelected()){
customFloatPositionButton.setSelected(true); customFloatPositionButton.setSelected(true);
checkArrangePaneVisible(); checkLayoutPaneVisible();
checkDisplayStrategyUse(); checkDisplayStrategyUse();
} }
} }
@ -330,16 +327,19 @@ public class VanChartPlotLegendPane extends BasicPane {
protected void checkAllUse() { protected void checkAllUse() {
checkBoxUse(); checkBoxUse();
checkArrangePaneVisible(); checkLayoutPaneVisible();
checkDisplayStrategyUse(); checkDisplayStrategyUse();
this.repaint(); this.repaint();
} }
protected void checkArrangePaneVisible() { protected void checkLayoutPaneVisible() {
boolean visible = !getCustomFloatPositionButton().isSelected() layoutPane.setVisible(isVisibleLayoutPane());
&& (getLegendLocation().getSelectedIndex() == 0 || getLegendLocation().getSelectedIndex() == 1); }
protected boolean isVisibleLayoutPane() {
int locationIndex = getLegendLocation().getSelectedIndex();
arrangePane.setVisible(visible); return !getCustomFloatPositionButton().isSelected() && (locationIndex == 0 || locationIndex == 1);
} }
//检查显示策略界面是否可用 //检查显示策略界面是否可用
@ -386,7 +386,7 @@ public class VanChartPlotLegendPane extends BasicPane {
legend.setPosition(-1); legend.setPosition(-1);
} }
legend.setFloating(customFloatPositionButton.isSelected()); legend.setFloating(customFloatPositionButton.isSelected());
legend.setArrange(arrangeButton.getSelectedItem()); legend.setLayout(layoutButton.getSelectedItem());
//区域显示策略 恢复用注释。下面2行删除。 //区域显示策略 恢复用注释。下面2行删除。
legend.setLimitSize(limitSize.getSelectedIndex() == 1); legend.setLimitSize(limitSize.getSelectedIndex() == 1);
legend.setMaxHeight(maxProportion.getValue()); legend.setMaxHeight(maxProportion.getValue());
@ -411,7 +411,7 @@ public class VanChartPlotLegendPane extends BasicPane {
customFloatPositionButton.setSelected(legend.isFloating()); customFloatPositionButton.setSelected(legend.isFloating());
customFloatPositionPane.setFloatPosition_x(legend.getFloatPercentX()); customFloatPositionPane.setFloatPosition_x(legend.getFloatPercentX());
customFloatPositionPane.setFloatPosition_y(legend.getFloatPercentY()); customFloatPositionPane.setFloatPosition_y(legend.getFloatPercentY());
arrangeButton.setSelectedItem(legend.getArrange()); layoutButton.setSelectedItem(legend.getLayout());
//区域显示策略 恢复用注释。下面2行删除。 //区域显示策略 恢复用注释。下面2行删除。
limitSize.setSelectedIndex(legend.isLimitSize() ? 1 : 0); limitSize.setSelectedIndex(legend.isLimitSize() ? 1 : 0);
maxProportion.setValue(legend.getMaxHeight()); maxProportion.setValue(legend.getMaxHeight());

11
designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java

@ -130,7 +130,7 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
checkCardPane(); checkCardPane();
checkArrangePaneVisible(); checkLayoutPaneVisible();
} }
}); });
} }
@ -143,18 +143,15 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane {
@Override @Override
protected void checkAllUse() { protected void checkAllUse() {
checkBoxUse(); checkBoxUse();
checkArrangePaneVisible(); checkLayoutPaneVisible();
checkDisplayStrategyUse(); checkDisplayStrategyUse();
checkCardPane(); checkCardPane();
this.repaint(); this.repaint();
} }
protected void checkArrangePaneVisible() { protected boolean isVisibleLayoutPane() {
boolean visible = legendTypeButton.getSelectedItem() != LegendType.GRADUAL
&& !getCustomFloatPositionButton().isSelected()
&& (getLegendLocation().getSelectedIndex() == 0 || getLegendLocation().getSelectedIndex() == 1);
getArrangePane().setVisible(visible); return super.isVisibleLayoutPane() && legendTypeButton.getSelectedItem() != LegendType.GRADUAL;
} }
private void checkHighlightVisible(){ private void checkHighlightVisible(){

Loading…
Cancel
Save