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.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<ChartProvider, ChartProvider> 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);

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.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<VanChart> calculateType(String tableName, List<String> columns) {
List<ColumnInfo> columnValue = calculateField(tableName, columns);
if (columnValue.isEmpty()) {
@ -86,9 +97,29 @@ public class AutoTypeCalculate {
return false;
}
}
//不是日期型数字才是指标
return !isNumberData(values);
}
private static boolean isNumberData(List<String> 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<ColumnInfo> calculateField(String tableName, List<String> columns) {
NameTableData nameTableData = new NameTableData(tableName);
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.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;
}
}

Loading…
Cancel
Save