From 1e415b0fc99c434ca5df25a2e55f2611ddbe3893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 7 Aug 2020 16:22:53 +0800 Subject: [PATCH] =?UTF-8?q?CHART-14999=20&&=20CHART-14811=20&&=20CHART-150?= =?UTF-8?q?10=09=20=E6=96=B0=E5=BB=BA=E5=9B=BE=E8=A1=A8=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=9B=BE=E4=BE=8B=E5=B7=A5=E5=85=B7=E6=A0=8F?= =?UTF-8?q?=20&&=20=E8=87=AA=E5=8A=A8=E6=8E=A8=E8=8D=90=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=88=A4=E6=96=AD=20&&=20=E7=BB=84=E5=90=88=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/chart/ChartTypePane.java | 10 +- .../design/chart/auto/AutoTypeCalculate.java | 31 ++++++ .../chart/gauge/VanChartGaugeSeriesPane.java | 100 +++++++++--------- 3 files changed, 90 insertions(+), 51 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index aab17780e..a5937c1d9 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/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.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.awt.Color; import java.awt.Component; @@ -35,6 +37,8 @@ public class ChartTypePane extends ChartCommonWizardPane implements CallbackEven private JList iconViewList = null; private DefaultListModel iconListModel = null; + private static Map map = new ConcurrentHashMap(); + public ChartTypePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); DefaultListModel defaultListModel = new DefaultListModel(); @@ -102,7 +106,11 @@ public class ChartTypePane extends ChartCommonWizardPane implements CallbackEven ChartTypePane.this.iconListModel.clear(); for (int i = 0, len = charts.length; i < len; 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.setChartName(subName[i]); chartIcon.registerCallBackEvent(ChartTypePane.this); diff --git a/designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java b/designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java index db20af8cf..c30679e0e 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/auto/AutoTypeCalculate.java +++ b/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.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * @author Bjorn @@ -30,6 +32,15 @@ import java.util.List; */ 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 calculateType(String tableName, List columns) { List columnValue = calculateField(tableName, columns); if (columnValue.isEmpty()) { @@ -86,9 +97,29 @@ public class AutoTypeCalculate { return false; } } + //不是日期型数字才是指标 + return !isNumberData(values); + } + + private static boolean isNumberData(List values) { + for (String value : values) { + if (!isNumberData(value)) { + return false; + } + } 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 calculateField(String tableName, List columns) { NameTableData nameTableData = new NameTableData(tableName); TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java index 858fb0ae7..7cc33a846 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java +++ b/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.stable.Constants; 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 javax.swing.JPanel; @@ -62,14 +61,20 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f}; - double[] rowSize = {p,p,p,p,p,p}; + double[] rowSize = {p, p, p, p, p, p}; Component[][] components = new Component[][]{ new Component[]{createGaugeLayoutPane()}, - new Component[]{createGaugeStylePane(rowSize, new double[]{f,e})}, + new Component[]{createGaugeStylePane(rowSize, new double[]{f, e})}, 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() { @@ -96,20 +101,20 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { } private void changeLabelPosition() { - if(plot instanceof VanChartGaugePlot){ - VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot; - if (ComparatorUtils.equals(gaugePlot.getGaugeStyle(), GaugeStyle.THERMOMETER)){ + if (plot instanceof VanChartGaugePlot) { + VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot; + if (ComparatorUtils.equals(gaugePlot.getGaugeStyle(), GaugeStyle.THERMOMETER)) { ConditionAttr attrList = gaugePlot.getConditionCollection().getDefaultAttr(); - AttrLabel attrLabel = (AttrLabel)attrList.getExisted(AttrLabel.class); - if(attrLabel == null){ + AttrLabel attrLabel = (AttrLabel) attrList.getExisted(AttrLabel.class); + if (attrLabel == null) { return; } AttrLabelDetail attrLabelDetail = attrLabel.getAttrLabelDetail(); - if(attrLabelDetail == null || attrLabelDetail.getTextAttr() == null){ + if (attrLabelDetail == null || attrLabelDetail.getTextAttr() == null) { return; } attrLabelDetail.getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_LABEL_FONT); - if(gaugeLayout.getSelectedIndex() == 0){ + if (gaugeLayout.getSelectedIndex() == 0) { attrLabel.getAttrLabelDetail().setPosition(Constants.LEFT); attrLabel.getGaugeValueLabelDetail().setPosition(Constants.LEFT); } else { @@ -124,7 +129,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { JPanel panel = new JPanel(new BorderLayout(0, 6)); JPanel centerPanel = TableLayoutHelper.createTableLayoutPane(getDiffComponentsWithGaugeStyle(), row, col); panel.add(centerPanel, BorderLayout.CENTER); - if(rotate != null){ + if (rotate != null) { JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Rotation_Direction"), rotate); panel.add(panel1, BorderLayout.NORTH); } @@ -132,7 +137,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { } private Component[][] getDiffComponentsWithGaugeStyle() { - GaugeStyle style = plot == null ? GaugeStyle.POINTER : ((VanChartGaugePlot)plot).getGaugeStyle(); + GaugeStyle style = plot == null ? GaugeStyle.POINTER : ((VanChartGaugePlot) plot).getGaugeStyle(); switch (style) { case RING: initRotate(); @@ -173,37 +178,37 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { private Component[] getHingeColor() { 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() { 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() { 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() { 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() { 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() { 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() { 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() { @@ -212,7 +217,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { private Component[] getInnerPaneBackgroundColor() { 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() { @@ -222,40 +227,40 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { public void populateBean(Plot plot) { - if(plot == null) { + if (plot == null) { return; } super.populateBean(plot); - if(plot instanceof VanChartGaugePlot){ - VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot; + if (plot instanceof VanChartGaugePlot) { + VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot; GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle(); gaugeLayout.setSelectedIndex(detailStyle.isHorizontalLayout() ? 0 : 1); - if(hingeColor != null){ + if (hingeColor != null) { hingeColor.setSelectObject(detailStyle.getHingeColor()); } - if(hingeBackgroundColor != null){ + if (hingeBackgroundColor != null) { hingeBackgroundColor.setSelectObject(detailStyle.getHingeBackgroundColor()); } - if(needleColor != null){ + if (needleColor != null) { needleColor.setSelectObject(detailStyle.getNeedleColor()); } - if(paneBackgroundColor != null){ + if (paneBackgroundColor != null) { paneBackgroundColor.setSelectObject(detailStyle.getPaneBackgroundColor()); } - if(slotBackgroundColor != null){ + if (slotBackgroundColor != null) { slotBackgroundColor.setSelectObject(detailStyle.getSlotBackgroundColor()); } - if(rotate != null){ + if (rotate != null) { rotate.setSelectedIndex(detailStyle.isAntiClockWise() ? 0 : 1); } - if(innerPaneBackgroundColor != null){ + if (innerPaneBackgroundColor != null) { innerPaneBackgroundColor.setSelectObject(detailStyle.getInnerPaneBackgroundColor()); } - if(thermometerWidth != null){ + if (thermometerWidth != null) { thermometerWidth.setValue(detailStyle.getThermometerWidth()); } - if(chutePercent != null){ + if (chutePercent != null) { chutePercent.populateBean(detailStyle.getChutePercent()); } @@ -265,50 +270,45 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane { @Override public void updateBean(Plot plot) { - if(plot == null){ + if (plot == null) { return; } super.updateBean(plot); - if(plot instanceof VanChartGaugePlot){ - VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot; + if (plot instanceof VanChartGaugePlot) { + VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot; GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle(); detailStyle.setHorizontalLayout(gaugeLayout.getSelectedIndex() == 0); - if(hingeColor != null){ + if (hingeColor != null) { detailStyle.setHingeColor(hingeColor.getSelectObject()); } - if(hingeBackgroundColor != null){ + if (hingeBackgroundColor != null) { detailStyle.setHingeBackgroundColor(hingeBackgroundColor.getSelectObject()); } - if(needleColor != null){ + if (needleColor != null) { detailStyle.setNeedleColor(needleColor.getSelectObject()); } - if(paneBackgroundColor != null){ + if (paneBackgroundColor != null) { detailStyle.setPaneBackgroundColor(paneBackgroundColor.getSelectObject()); } - if(slotBackgroundColor != null){ + if (slotBackgroundColor != null) { detailStyle.setSlotBackgroundColor(slotBackgroundColor.getSelectObject()); } - if(rotate != null){ + if (rotate != null) { detailStyle.setAntiClockWise(rotate.getSelectedIndex() == 0); } - if(innerPaneBackgroundColor != null){ + if (innerPaneBackgroundColor != null) { detailStyle.setInnerPaneBackgroundColor(innerPaneBackgroundColor.getSelectObject()); } - if(thermometerWidth != null){ + if (thermometerWidth != null) { detailStyle.setThermometerWidth(thermometerWidth.getValue()); } - if(chutePercent != null){ + if (chutePercent != null) { detailStyle.setChutePercent(chutePercent.updateBean()); } colorPickerPane.updateBean(detailStyle.getHotAreaColor()); } } - - @Override - protected VanChartBeautyPane createStylePane() { - return null; - } }