Browse Source

CHART-10225 轴标签重叠策略 兼容

persist/11.0
zheng 5 years ago
parent
commit
10d1c04355
  1. 128
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java
  2. 5
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java
  3. 5
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java

128
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java

@ -12,8 +12,9 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.style.FormatPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.PaneTitleConstants;
@ -22,11 +23,13 @@ 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.attr.axis.VanChartAxis;
import com.fr.plugin.chart.base.OverlapHandleType;
import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.plugin.chart.type.AxisTickLineType;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartHtmlLabelPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
@ -36,6 +39,8 @@ import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
@ -58,10 +63,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected UIButtonGroup showLabel;
protected ChartTextAttrPane labelTextAttrPane;
protected UINumberDragPane labelTextRotation;
private UIButtonGroup<OverlapHandleType> overlapHandleTypeGroup;
protected UIButtonGroup<Integer> labelGapStyle;
protected UITextField labelGapValue;
protected JPanel labelPanel;
protected UISpinner labelGapValue;
protected JPanel labelPanel;
private JPanel labelGapStylePane;
private JPanel labelGapValuePane;
protected LineComboBox axisLineStyle;
protected ColorSelectBox axisLineColor;
@ -77,7 +86,6 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
protected FormatPane valueFormat;
protected JPanel centerPane;
private VanChartHtmlLabelPane htmlLabelPane;
private JPanel labelGapValuePane;
public VanChartBaseAxisPane(){
this(true);
@ -164,32 +172,22 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
}
protected JPanel createLabelPane(double[] row, double[] col){
double p = TableLayout.PREFERRED;
showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")});
labelTextAttrPane = getChartTextAttrPane();
labelTextRotation = new UINumberDragPane(-ROTATION_MAX,ROTATION_MAX);
labelGapStyle = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fixed")});
labelGapValue = new UITextField();
Component[][] gapComponents = new Component[][]{
new Component[]{
FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")),
UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation)
},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Label_Interval")), labelGapStyle},
};
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, row, col);
labelGapValuePane= TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText(""),labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
JPanel gapPanel = new JPanel(new BorderLayout());
gapPanel.add(panel, BorderLayout.CENTER);
gapPanel.add(labelGapValuePane, BorderLayout.SOUTH);
JPanel rotationPane = createLabelRotationPane(col);
JPanel overlapPane = createLabelOverlapPane();
Component[][] components = new Component[][]{
Component[][] components = new Component[][]{
new Component[]{labelTextAttrPane, null},
new Component[]{gapPanel,null},
new Component[]{rotationPane, null},
new Component[]{overlapPane, null},
};
JPanel showLabelPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"),showLabel);
labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col);
labelPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p}, col);
labelPanel.setBorder(BorderFactory.createEmptyBorder(0,10,0,0));
showLabel.addActionListener(new ActionListener() {
@Override
@ -197,16 +195,61 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
checkLabelPane();
}
});
JPanel jPanel = new JPanel(new BorderLayout());
jPanel.add(showLabelPane, BorderLayout.NORTH);
jPanel.add(labelPanel, BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, jPanel);
}
private JPanel createLabelRotationPane(double[] col) {
labelTextRotation = new UINumberDragPane(-ROTATION_MAX, ROTATION_MAX);
Component[][] gapComponents = new Component[][]{
new Component[]{
FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TextRotation")),
UIComponentUtils.wrapWithBorderLayoutPane(labelTextRotation)
}
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(gapComponents, new double[]{TableLayout.PREFERRED}, col);
}
private JPanel createLabelOverlapPane() {
labelGapStyle = new UIButtonGroup<Integer>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Fixed")});
labelGapStylePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_Interval"), labelGapStyle, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
labelGapValue = new UISpinner(0, Integer.MAX_VALUE, 1, 1);
labelGapValuePane = TableLayout4VanChartHelper.createGapTableLayoutPane(StringUtils.EMPTY, labelGapValue, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
JPanel panel = new JPanel(new BorderLayout(0, 0));
addOverlapGroupButton(panel);
panel.add(labelGapStylePane, BorderLayout.CENTER);
panel.add(labelGapValuePane, BorderLayout.SOUTH);
labelGapStyle.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkLabelGapValuePane();
}
});
JPanel jPanel = new JPanel(new BorderLayout());
jPanel.add(showLabelPane, BorderLayout.NORTH);
jPanel.add(labelPanel, BorderLayout.CENTER);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, jPanel);
return panel;
}
protected void addOverlapGroupButton(JPanel panel) {
overlapHandleTypeGroup = new UIButtonGroup<OverlapHandleType>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Label_OverlapAbbreviate"), Toolkit.i18nText("Fine-Design_Chart_Label_OverlapInterval")},
new OverlapHandleType[]{OverlapHandleType.ABBREVIATE, OverlapHandleType.INTERVAL});
JPanel north = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Label_WhenOverlap"), overlapHandleTypeGroup, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH);
panel.add(north, BorderLayout.NORTH);
overlapHandleTypeGroup.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
checkLabelGapAndStylePane();
}
});
}
protected ChartTextAttrPane getChartTextAttrPane(){
@ -362,14 +405,27 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
labelPanel.setVisible(enabled);
}
if(enabled){
checkLabelGapValuePane();
checkLabelGapAndStylePane();
}
}
}
private void checkLabelGapAndStylePane() {
if (overlapHandleTypeGroup != null && labelGapStylePane != null) {
boolean visible = overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL;
labelGapStylePane.setVisible(visible);
}
checkLabelGapValuePane();
}
protected void checkLabelGapValuePane() {
if(labelGapValuePane != null && labelGapStyle != null){
labelGapValuePane.setVisible(labelGapStyle.getSelectedIndex() == 1);
if (labelGapValuePane != null && labelGapStyle != null) {
boolean visible = labelGapStyle.getSelectedIndex() == 1;
if (overlapHandleTypeGroup != null) {
visible = visible && overlapHandleTypeGroup.getSelectedItem() == OverlapHandleType.INTERVAL;
}
labelGapValuePane.setVisible(visible);
}
}
@ -452,11 +508,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
if(labelTextRotation != null){
labelTextRotation.populateBean((double)labelTextAttr.getRotation());
}
if (overlapHandleTypeGroup != null) {
overlapHandleTypeGroup.setSelectedItem(axis.getOverlapHandleType());
}
if(labelGapStyle != null){
labelGapStyle.setSelectedIndex(axis.isAutoLabelGap() ? 0 : 1);
}
if(labelGapValue != null){
labelGapValue.setText(axis.getLabelNumber().getContent());
labelGapValue.setValue(axis.getIntervalNumber());
}
}
@ -568,15 +627,14 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane<VanChartAxis> {
if(labelTextRotation != null){
labelTextAttr.setRotation(labelTextRotation.updateBean().intValue());
}
if (overlapHandleTypeGroup != null) {
axis.setOverlapHandleType(overlapHandleTypeGroup.getSelectedItem());
}
if(labelGapStyle != null){
axis.setAutoLabelGap(labelGapStyle.getSelectedIndex() == 0);
}
if(labelGapValue != null){
if(axis.isAutoLabelGap()){
axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build("1"));
} else {
axis.setLabelIntervalNumber(BaseFormula.createFormulaBuilder().build(labelGapValue.getText()));
}
axis.setIntervalNumber((int) labelGapValue.getValue());
}
}

5
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartTimeAxisPane.java

@ -17,7 +17,6 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.DateUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartTimeAxis;
import com.fr.plugin.chart.base.VanChartConstants;
@ -80,6 +79,10 @@ public class VanChartTimeAxisPane extends VanChartBaseAxisPane {
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
@Override
protected void addOverlapGroupButton(JPanel panel) {
}
private JPanel createValueDefinition(){
timeMinMaxValuePane = new TimeMinMaxValuePane();
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), timeMinMaxValuePane);

5
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartValueAxisPane.java

@ -7,7 +7,6 @@ import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartValueAxis;
import com.fr.stable.StringUtils;
@ -61,6 +60,10 @@ public class VanChartValueAxisPane extends VanChartBaseAxisPane {
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
@Override
protected void addOverlapGroupButton(JPanel panel) {
}
protected JPanel createMinMaxValuePane(double[] row, double[] col){
JPanel panel = createCommenValuePane(row,col);
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), panel);

Loading…
Cancel
Save