Browse Source

CHART-14999 && CHART-14811 && CHART-15010 新建图表去掉标题图例工具栏 && 自动推荐时间判断 && 组合地图面板调整

feature/big-screen
白岳 4 years ago
parent
commit
1e415b0fc9
  1. 10
      designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java
  2. 31
      designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java
  3. 100
      designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java

10
designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java

@ -23,6 +23,8 @@ import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionListener;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -35,6 +37,8 @@ public class ChartTypePane extends ChartCommonWizardPane implements CallbackEven
private JList iconViewList = null; private JList iconViewList = null;
private DefaultListModel iconListModel = null; private DefaultListModel iconListModel = null;
private static Map<ChartProvider, ChartProvider> map = new ConcurrentHashMap();
public ChartTypePane() { public ChartTypePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
DefaultListModel defaultListModel = new DefaultListModel(); DefaultListModel defaultListModel = new DefaultListModel();
@ -102,7 +106,11 @@ public class ChartTypePane extends ChartCommonWizardPane implements CallbackEven
ChartTypePane.this.iconListModel.clear(); ChartTypePane.this.iconListModel.clear();
for (int i = 0, len = charts.length; i < len; i++) { for (int i = 0, len = charts.length; i < len; i++) {
ChartProvider chart = charts[i]; ChartProvider chart = charts[i];
ChartCollection chartCollection = new ChartCollection(chart); if (map.get(chart) == null) {
ChartProvider chartProvider = chart.transformProperties();
map.put(chart, chartProvider);
}
ChartCollection chartCollection = new ChartCollection(map.get(chart));
ChartIcon chartIcon = new ChartIcon(chartCollection); ChartIcon chartIcon = new ChartIcon(chartCollection);
chartIcon.setChartName(subName[i]); chartIcon.setChartName(subName[i]);
chartIcon.registerCallBackEvent(ChartTypePane.this); chartIcon.registerCallBackEvent(ChartTypePane.this);

31
designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java

@ -22,6 +22,8 @@ import com.fr.stable.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* @author Bjorn * @author Bjorn
@ -30,6 +32,15 @@ import java.util.List;
*/ */
public class AutoTypeCalculate { public class AutoTypeCalculate {
public static Pattern[] dataPatterns;
static {
Pattern pattern1 = Pattern.compile("^(19|20)\\d{2}$");
Pattern pattern2 = Pattern.compile("^\\d{4}(0?[1-9]|1[012])$");
Pattern pattern3 = Pattern.compile("^\\d{4}(0?[1-9]|1[012])(0?[1-9]|[12]\\d|3[01])$");
dataPatterns = new Pattern[]{pattern1, pattern2, pattern3};
}
public static List<VanChart> calculateType(String tableName, List<String> columns) { public static List<VanChart> calculateType(String tableName, List<String> columns) {
List<ColumnInfo> columnValue = calculateField(tableName, columns); List<ColumnInfo> columnValue = calculateField(tableName, columns);
if (columnValue.isEmpty()) { if (columnValue.isEmpty()) {
@ -86,9 +97,29 @@ public class AutoTypeCalculate {
return false; return false;
} }
} }
//不是日期型数字才是指标
return !isNumberData(values);
}
private static boolean isNumberData(List<String> values) {
for (String value : values) {
if (!isNumberData(value)) {
return false;
}
}
return true; return true;
} }
private static boolean isNumberData(String value) {
for (Pattern pattern : dataPatterns) {
Matcher matcher = pattern.matcher(value);
if (matcher.matches()) {
return true;
}
}
return false;
}
private static List<ColumnInfo> calculateField(String tableName, List<String> columns) { private static List<ColumnInfo> calculateField(String tableName, List<String> columns) {
NameTableData nameTableData = new NameTableData(tableName); NameTableData nameTableData = new NameTableData(tableName);
TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget());

100
designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java

@ -21,7 +21,6 @@ import com.fr.plugin.chart.gauge.VanChartGaugePlot;
import com.fr.plugin.chart.type.GaugeStyle; import com.fr.plugin.chart.type.GaugeStyle;
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.VanChartBeautyPane;
import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -62,14 +61,20 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
double f = TableLayout.FILL; double f = TableLayout.FILL;
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f}; double[] columnSize = {f};
double[] rowSize = {p,p,p,p,p,p}; double[] rowSize = {p, p, p, p, p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{createGaugeLayoutPane()}, new Component[]{createGaugeLayoutPane()},
new Component[]{createGaugeStylePane(rowSize, new double[]{f,e})}, new Component[]{createGaugeStylePane(rowSize, new double[]{f, e})},
new Component[]{createGaugeBandsPane()} new Component[]{createGaugeBandsPane()}
}; };
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
//获取颜色面板
protected JPanel getColorPane() {
JPanel panel = new JPanel(new BorderLayout());
return panel;
} }
private JPanel createGaugeLayoutPane() { private JPanel createGaugeLayoutPane() {
@ -96,20 +101,20 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
} }
private void changeLabelPosition() { private void changeLabelPosition() {
if(plot instanceof VanChartGaugePlot){ if (plot instanceof VanChartGaugePlot) {
VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot; VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot;
if (ComparatorUtils.equals(gaugePlot.getGaugeStyle(), GaugeStyle.THERMOMETER)){ if (ComparatorUtils.equals(gaugePlot.getGaugeStyle(), GaugeStyle.THERMOMETER)) {
ConditionAttr attrList = gaugePlot.getConditionCollection().getDefaultAttr(); ConditionAttr attrList = gaugePlot.getConditionCollection().getDefaultAttr();
AttrLabel attrLabel = (AttrLabel)attrList.getExisted(AttrLabel.class); AttrLabel attrLabel = (AttrLabel) attrList.getExisted(AttrLabel.class);
if(attrLabel == null){ if (attrLabel == null) {
return; return;
} }
AttrLabelDetail attrLabelDetail = attrLabel.getAttrLabelDetail(); AttrLabelDetail attrLabelDetail = attrLabel.getAttrLabelDetail();
if(attrLabelDetail == null || attrLabelDetail.getTextAttr() == null){ if (attrLabelDetail == null || attrLabelDetail.getTextAttr() == null) {
return; return;
} }
attrLabelDetail.getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_LABEL_FONT); attrLabelDetail.getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_LABEL_FONT);
if(gaugeLayout.getSelectedIndex() == 0){ if (gaugeLayout.getSelectedIndex() == 0) {
attrLabel.getAttrLabelDetail().setPosition(Constants.LEFT); attrLabel.getAttrLabelDetail().setPosition(Constants.LEFT);
attrLabel.getGaugeValueLabelDetail().setPosition(Constants.LEFT); attrLabel.getGaugeValueLabelDetail().setPosition(Constants.LEFT);
} else { } else {
@ -124,7 +129,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
JPanel panel = new JPanel(new BorderLayout(0, 6)); JPanel panel = new JPanel(new BorderLayout(0, 6));
JPanel centerPanel = TableLayoutHelper.createTableLayoutPane(getDiffComponentsWithGaugeStyle(), row, col); JPanel centerPanel = TableLayoutHelper.createTableLayoutPane(getDiffComponentsWithGaugeStyle(), row, col);
panel.add(centerPanel, BorderLayout.CENTER); panel.add(centerPanel, BorderLayout.CENTER);
if(rotate != null){ if (rotate != null) {
JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Rotation_Direction"), rotate); JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Rotation_Direction"), rotate);
panel.add(panel1, BorderLayout.NORTH); panel.add(panel1, BorderLayout.NORTH);
} }
@ -132,7 +137,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
} }
private Component[][] getDiffComponentsWithGaugeStyle() { private Component[][] getDiffComponentsWithGaugeStyle() {
GaugeStyle style = plot == null ? GaugeStyle.POINTER : ((VanChartGaugePlot)plot).getGaugeStyle(); GaugeStyle style = plot == null ? GaugeStyle.POINTER : ((VanChartGaugePlot) plot).getGaugeStyle();
switch (style) { switch (style) {
case RING: case RING:
initRotate(); initRotate();
@ -173,37 +178,37 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
private Component[] getHingeColor() { private Component[] getHingeColor() {
hingeColor = new ColorSelectBox(120); hingeColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge")),hingeColor}; return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge")), hingeColor};
} }
private Component[] getHingeBackgroundColor() { private Component[] getHingeBackgroundColor() {
hingeBackgroundColor = new ColorSelectBox(120); hingeBackgroundColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge_Background")),hingeBackgroundColor}; return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge_Background")), hingeBackgroundColor};
} }
private Component[] getNeedleColor() { private Component[] getNeedleColor() {
needleColor = new ColorSelectBox(120); needleColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Needle")),needleColor}; return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Needle")), needleColor};
} }
private Component[] getPaneBackgroundColor() { private Component[] getPaneBackgroundColor() {
paneBackgroundColor = new ColorSelectBox(120); paneBackgroundColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Pane_Background")),paneBackgroundColor}; return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Pane_Background")), paneBackgroundColor};
} }
private Component[] getSlotBackgroundColor() { private Component[] getSlotBackgroundColor() {
slotBackgroundColor = new ColorSelectBox(120); slotBackgroundColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Slot_Background")),slotBackgroundColor}; return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Slot_Background")), slotBackgroundColor};
} }
private Component[] getThermometerWidth() { private Component[] getThermometerWidth() {
thermometerWidth = new UISpinner(0, Double.MAX_VALUE, 0.1, 10); thermometerWidth = new UISpinner(0, Double.MAX_VALUE, 0.1, 10);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Thermometer_Width")),thermometerWidth}; return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Thermometer_Width")), thermometerWidth};
} }
private Component[] getChutePercent() { private Component[] getChutePercent() {
chutePercent = new UINumberDragPane(0, 100, 1); chutePercent = new UINumberDragPane(0, 100, 1);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Chute_Percent")),chutePercent}; return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Chute_Percent")), chutePercent};
} }
private void initRotate() { private void initRotate() {
@ -212,7 +217,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
private Component[] getInnerPaneBackgroundColor() { private Component[] getInnerPaneBackgroundColor() {
innerPaneBackgroundColor = new ColorSelectBox(120); innerPaneBackgroundColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Inner_Pane_Background")),innerPaneBackgroundColor}; return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Inner_Pane_Background")), innerPaneBackgroundColor};
} }
private JPanel createGaugeBandsPane() { private JPanel createGaugeBandsPane() {
@ -222,40 +227,40 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
public void populateBean(Plot plot) { public void populateBean(Plot plot) {
if(plot == null) { if (plot == null) {
return; return;
} }
super.populateBean(plot); super.populateBean(plot);
if(plot instanceof VanChartGaugePlot){ if (plot instanceof VanChartGaugePlot) {
VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot; VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot;
GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle(); GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle();
gaugeLayout.setSelectedIndex(detailStyle.isHorizontalLayout() ? 0 : 1); gaugeLayout.setSelectedIndex(detailStyle.isHorizontalLayout() ? 0 : 1);
if(hingeColor != null){ if (hingeColor != null) {
hingeColor.setSelectObject(detailStyle.getHingeColor()); hingeColor.setSelectObject(detailStyle.getHingeColor());
} }
if(hingeBackgroundColor != null){ if (hingeBackgroundColor != null) {
hingeBackgroundColor.setSelectObject(detailStyle.getHingeBackgroundColor()); hingeBackgroundColor.setSelectObject(detailStyle.getHingeBackgroundColor());
} }
if(needleColor != null){ if (needleColor != null) {
needleColor.setSelectObject(detailStyle.getNeedleColor()); needleColor.setSelectObject(detailStyle.getNeedleColor());
} }
if(paneBackgroundColor != null){ if (paneBackgroundColor != null) {
paneBackgroundColor.setSelectObject(detailStyle.getPaneBackgroundColor()); paneBackgroundColor.setSelectObject(detailStyle.getPaneBackgroundColor());
} }
if(slotBackgroundColor != null){ if (slotBackgroundColor != null) {
slotBackgroundColor.setSelectObject(detailStyle.getSlotBackgroundColor()); slotBackgroundColor.setSelectObject(detailStyle.getSlotBackgroundColor());
} }
if(rotate != null){ if (rotate != null) {
rotate.setSelectedIndex(detailStyle.isAntiClockWise() ? 0 : 1); rotate.setSelectedIndex(detailStyle.isAntiClockWise() ? 0 : 1);
} }
if(innerPaneBackgroundColor != null){ if (innerPaneBackgroundColor != null) {
innerPaneBackgroundColor.setSelectObject(detailStyle.getInnerPaneBackgroundColor()); innerPaneBackgroundColor.setSelectObject(detailStyle.getInnerPaneBackgroundColor());
} }
if(thermometerWidth != null){ if (thermometerWidth != null) {
thermometerWidth.setValue(detailStyle.getThermometerWidth()); thermometerWidth.setValue(detailStyle.getThermometerWidth());
} }
if(chutePercent != null){ if (chutePercent != null) {
chutePercent.populateBean(detailStyle.getChutePercent()); chutePercent.populateBean(detailStyle.getChutePercent());
} }
@ -265,50 +270,45 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
@Override @Override
public void updateBean(Plot plot) { public void updateBean(Plot plot) {
if(plot == null){ if (plot == null) {
return; return;
} }
super.updateBean(plot); super.updateBean(plot);
if(plot instanceof VanChartGaugePlot){ if (plot instanceof VanChartGaugePlot) {
VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot; VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot;
GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle(); GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle();
detailStyle.setHorizontalLayout(gaugeLayout.getSelectedIndex() == 0); detailStyle.setHorizontalLayout(gaugeLayout.getSelectedIndex() == 0);
if(hingeColor != null){ if (hingeColor != null) {
detailStyle.setHingeColor(hingeColor.getSelectObject()); detailStyle.setHingeColor(hingeColor.getSelectObject());
} }
if(hingeBackgroundColor != null){ if (hingeBackgroundColor != null) {
detailStyle.setHingeBackgroundColor(hingeBackgroundColor.getSelectObject()); detailStyle.setHingeBackgroundColor(hingeBackgroundColor.getSelectObject());
} }
if(needleColor != null){ if (needleColor != null) {
detailStyle.setNeedleColor(needleColor.getSelectObject()); detailStyle.setNeedleColor(needleColor.getSelectObject());
} }
if(paneBackgroundColor != null){ if (paneBackgroundColor != null) {
detailStyle.setPaneBackgroundColor(paneBackgroundColor.getSelectObject()); detailStyle.setPaneBackgroundColor(paneBackgroundColor.getSelectObject());
} }
if(slotBackgroundColor != null){ if (slotBackgroundColor != null) {
detailStyle.setSlotBackgroundColor(slotBackgroundColor.getSelectObject()); detailStyle.setSlotBackgroundColor(slotBackgroundColor.getSelectObject());
} }
if(rotate != null){ if (rotate != null) {
detailStyle.setAntiClockWise(rotate.getSelectedIndex() == 0); detailStyle.setAntiClockWise(rotate.getSelectedIndex() == 0);
} }
if(innerPaneBackgroundColor != null){ if (innerPaneBackgroundColor != null) {
detailStyle.setInnerPaneBackgroundColor(innerPaneBackgroundColor.getSelectObject()); detailStyle.setInnerPaneBackgroundColor(innerPaneBackgroundColor.getSelectObject());
} }
if(thermometerWidth != null){ if (thermometerWidth != null) {
detailStyle.setThermometerWidth(thermometerWidth.getValue()); detailStyle.setThermometerWidth(thermometerWidth.getValue());
} }
if(chutePercent != null){ if (chutePercent != null) {
detailStyle.setChutePercent(chutePercent.updateBean()); detailStyle.setChutePercent(chutePercent.updateBean());
} }
colorPickerPane.updateBean(detailStyle.getHotAreaColor()); colorPickerPane.updateBean(detailStyle.getHotAreaColor());
} }
} }
@Override
protected VanChartBeautyPane createStylePane() {
return null;
}
} }

Loading…
Cancel
Save