Browse Source

CHART-9435 试管型仪表盘纵向位置优化

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
2da7596a92
  1. 10
      designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java
  2. 134
      designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java
  3. 10
      designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java
  4. 26
      designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java

10
designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java

@ -4,8 +4,6 @@ import com.fr.chart.chartattr.Plot;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.plugin.chart.gauge.VanChartGaugePlot;
import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.label.LabelContentPaneWithCate;
@ -24,8 +22,6 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe
private static final long serialVersionUID = 5176535960949074945L;
private GaugeStyle gaugeStyle;
public VanChartGaugeCateOrPercentLabelDetailPane(Plot plot, VanChartStylePane parent) {
super(plot, parent);
}
@ -34,12 +30,6 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe
return hasLabelPosition(plot) ? new double[]{p,p,p} : new double[]{p,p};
}
private void initGaugeStyle(Plot plot) {
if(gaugeStyle == null){
gaugeStyle = ((VanChartGaugePlot)plot).getGaugeStyle();
}
}
protected void initToolTipContentPane(Plot plot) {
initGaugeStyle(plot);
switch (gaugeStyle){

134
designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java

@ -1,14 +1,25 @@
package com.fr.van.chart.designer.style.label;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.Plot;
import com.fr.chartx.TwoTuple;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.base.AttrLabelDetail;
import com.fr.plugin.chart.gauge.VanChartGaugePlot;
import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.stable.Constants;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
/**
@ -16,10 +27,21 @@ import java.awt.Component;
*/
public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane {
protected GaugeStyle gaugeStyle;
protected UIButtonGroup<Integer> align;
private JPanel alignPane;
protected Integer[] oldAlignValues;
public VanChartGaugeLabelDetailPane(Plot plot, VanChartStylePane parent) {
super(plot, parent);
}
protected void initGaugeStyle(Plot plot) {
if (gaugeStyle == null) {
gaugeStyle = ((VanChartGaugePlot) plot).getGaugeStyle();
}
}
protected JPanel createLabelStylePane(double[] row, double[] col, Plot plot) {
style = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")});
@ -30,16 +52,118 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane {
return TableLayoutHelper.createTableLayoutPane(getLabelStyleComponents(plot), row, col);
}
protected ChartTextAttrPane initTextFontPane () {
protected ChartTextAttrPane initTextFontPane() {
return new ChartTextAttrPane();
}
protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){
return TableLayoutHelper.createTableLayoutPane(comps,row,col);
protected JPanel getLabelPositionPane(Component[][] comps, double[] row, double[] col) {
return TableLayoutHelper.createTableLayoutPane(comps, row, col);
}
protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) {
return TableLayout4VanChartHelper.createGapTableLayoutPane(title, panel);
}
protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) {
if (hasLabelAlign(plot)) {
return new Component[][]{
new Component[]{dataLabelContentPane, null},
new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical"), plot), null},
new Component[]{createLabelAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")), null},
new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null},
};
} else {
return super.getLabelPaneComponents(plot, p, columnSize);
}
}
private JPanel createLabelAlignPane(String title) {
JPanel panel = new JPanel(new BorderLayout());
alignPane = new JPanel();
checkAlignPane(title);
panel.add(alignPane, BorderLayout.CENTER);
return panel;
}
protected void checkAlignPane(String title) {
if (alignPane == null && !hasLabelAlign(getPlot())) {
return;
}
if (alignPane != null && !hasLabelAlign(getPlot())) {
oldAlignValues = null;
alignPane.removeAll();
return;
}
if (alignPane == null && hasLabelAlign(getPlot())) {
alignPane = new JPanel();
}
TwoTuple<String[], Integer[]> result = getAlignNamesAndValues();
String[] names = result.getFirst();
Integer[] values = result.getSecond();
if (ComparatorUtils.equals(values, oldAlignValues)) {
return;
}
oldAlignValues = values;
align = new UIButtonGroup<Integer>(names, values);
Component[][] comps = new Component[2][2];
comps[0] = new Component[]{null, null};
comps[1] = new Component[]{new UILabel(title, SwingConstants.LEFT), align};
double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED};
double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH};
alignPane.removeAll();
alignPane.setLayout(new BorderLayout());
alignPane.add(getLabelPositionPane(comps, row, col), BorderLayout.CENTER);
if (parent != null) {
parent.initListener(alignPane);
}
}
private TwoTuple<String[], Integer[]> getAlignNamesAndValues() {
String[] names = new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow"), Toolkit.i18nText("Fine-Design_Chart_Align_Left"), Toolkit.i18nText("Fine-Design_Chart_Align_Right")};
Integer[] values = new Integer[]{ChartConstants.AUTO_LABEL_POSITION, Constants.LEFT, Constants.RIGHT};
return new TwoTuple<>(names, values);
}
protected void checkPane() {
String verticalTitle = hasLabelAlign(getPlot())
? Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical")
: Toolkit.i18nText("Fine-Design_Chart_Layout_Position");
checkPositionPane(verticalTitle);
checkAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal"));
}
private boolean hasLabelAlign(Plot plot) {
return ComparatorUtils.equals(gaugeStyle, GaugeStyle.THERMOMETER) && !((VanChartGaugePlot) plot).getGaugeDetailStyle().isHorizontalLayout();
}
public void populate(AttrLabelDetail detail) {
super.populate(detail);
if (hasLabelAlign(this.getPlot()) && align != null) {
align.setSelectedItem(detail.getAlign());
}
}
public void update(AttrLabelDetail detail) {
super.update(detail);
if (align != null && align.getSelectedItem() != null) {
detail.setAlign(align.getSelectedItem());
} else if (align != null) {
align.setSelectedItem(detail.getAlign());
}
}
}

10
designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java

@ -1,8 +1,6 @@
package com.fr.van.chart.designer.style.label;
import com.fr.chart.chartattr.Plot;
import com.fr.plugin.chart.gauge.VanChartGaugePlot;
import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.label.LabelContentPaneWithCateValue;
import com.fr.van.chart.designer.component.label.LabelContentPaneWithOutCate;
@ -17,18 +15,10 @@ import java.awt.Component;
public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailPane {
private static final long serialVersionUID = 2601073419430634281L;
private GaugeStyle gaugeStyle;
public VanChartGaugeValueLabelDetailPane(Plot plot, VanChartStylePane parent) {
super(plot, parent);
}
private void initGaugeStyle(Plot plot) {
if(gaugeStyle == null){
gaugeStyle = ((VanChartGaugePlot)plot).getGaugeStyle();
}
}
protected void initToolTipContentPane(Plot plot) {
initGaugeStyle(plot);
switch (gaugeStyle){

26
designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java

@ -11,6 +11,7 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.attr.plot.VanChartLabelPositionPlot;
@ -65,6 +66,10 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
this.add(contentPane,BorderLayout.CENTER);
}
public Plot getPlot() {
return plot;
}
//默认从factory中取
protected void initToolTipContentPane(Plot plot) {
dataLabelContentPane = PlotFactory.createPlotLabelContentPane(plot, parent, VanChartPlotLabelDetailPane.this);
@ -85,7 +90,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
if(hasLabelPosition(plot)){
return new Component[][]{
new Component[]{dataLabelContentPane,null},
new Component[]{createLabelPositionPane(new double[]{p,p,p}, columnSize, plot),null},
new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null},
new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot),null},
};
} else {
@ -112,7 +117,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel);
}
private TwoTuple<String[], Integer[]> getPositionNamesAndValues() {
protected TwoTuple<String[], Integer[]> getPositionNamesAndValues() {
if (plot instanceof VanChartLabelPositionPlot) {
String[] names = ((VanChartLabelPositionPlot) plot).getLabelLocationNameArray();
@ -130,7 +135,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
return null;
}
private JPanel createLabelPositionPane(double[] row, double[] col, Plot plot) {
protected JPanel createLabelPositionPane(String title, Plot plot) {
if (getPositionNamesAndValues() == null) {
return new JPanel();
@ -141,7 +146,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
JPanel panel = new JPanel(new BorderLayout());
positionPane = new JPanel();
checkPositionPane();
checkPositionPane(title);
panel.add(positionPane, BorderLayout.CENTER);
@ -156,7 +161,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
return panel;
}
private void checkPositionPane() {
protected void checkPositionPane(String title) {
if (positionPane == null) {
return;
}
@ -176,7 +181,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
Component[][] comps = new Component[2][2];
comps[0] = new Component[]{null, null};
comps[1] = new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), SwingConstants.LEFT), position};
comps[1] = new Component[]{new UILabel(title, SwingConstants.LEFT), position};
double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED};
double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH};
@ -277,9 +282,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
tractionLinePane.setVisible(position.getSelectedItem() == Constants.OUTSIDE);
}
public void populate(AttrLabelDetail detail) {
checkPositionPane();
protected void checkPane(){
checkPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"));
}
public void populate(AttrLabelDetail detail) {
checkPane();
dataLabelContentPane.populateBean(detail.getContent());
if(position != null){
position.setSelectedItem(detail.getPosition());
@ -306,7 +314,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane {
if(position != null && position.getSelectedItem() != null){
detail.setPosition(position.getSelectedItem());
} else if(position != null){
position.setSelectedItem(detail.getPosition());
}

Loading…
Cancel
Save