Browse Source

CHART-21357 fix:新增坐标轴样式

zheng-1641779399395
shine 3 years ago
parent
commit
ba77f3016e
  1. 89
      designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java
  2. 87
      designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleHelper4Van.java
  3. 3
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java
  4. 7
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java
  5. 9
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisScrollPaneWithTypeSelect.java

89
designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java

@ -0,0 +1,89 @@
package com.fr.van.chart.config;
import com.fr.base.ChartPreStyleConfig;
import com.fr.chart.base.ChartBaseUtils;
import com.fr.chart.base.ChartConstants;
import com.fr.general.Background;
import com.fr.general.FRFont;
import com.fr.general.GeneralUtils;
import com.fr.stable.CodeUtils;
import com.fr.stable.Constants;
import java.awt.Color;
import java.awt.Font;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/6/25
*/
public class DefaultStyleConstants {
static final FRFont TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.BOLD, 14, new Color(241, 246, 255));
static final FRFont LEGEND = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191));
static final FRFont AXIS_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191));
static final FRFont AXIS_TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(200, 211, 228));
static final Color AXIS_LINE = new Color(46, 75, 102);
static final Color GRID_LINE = new Color(30, 55, 78);
static final FRFont DATA_SHEET = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191));
static final Color DATA_SHEET_BORDER = new Color(46, 75, 102);
static final Color BORDER = Color.BLACK;
static final int BORDER_WIDTH = Constants.LINE_NONE;
static final int SPECIAL_BORDER_WIDTH = Constants.LINE_THIN;
static final FRFont PIE_CATEGORY_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 10, new Color(232, 232, 232));
static final Color GAUGE_PANE_BACK_COLOR = null;
static final Color GAUGE_HINGE = null;
static final Color GAUGE_PANE_BACK_COLOR_4_RING = new Color(72, 73, 79);
static final Color GAUGE_SLOT_BACKGROUND_COLOR = new Color(72, 73, 79);
private static final String FONT_NAME = ChartBaseUtils.getLocalDefaultFont("verdana");
static final FRFont THERMOMETER_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.BOLD, 9, new Color(232, 232, 232));//试管仪表盘标签的默认样式
static final FRFont THERMOMETER_AXIS_LABEL = FRFont.getInstance(FONT_NAME, Font.PLAIN, 8, new Color(159, 173, 191));
static final FRFont RING_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//百分比圆环仪表盘值标签的默认样式
static final FRFont POINTER_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//多指针仪表盘值标签的默认样式
static final FRFont POINTER_CATE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, 10, new Color(232, 232, 232));//多指针仪表盘分类标签的默认样式
static final Color MAP_NULL_VALUE_COLOR = new Color(168, 168, 168);
static final Color MAP_BORDER = Color.BLACK;
static final Color MAP_LEGEND_BACK = Color.BLACK;
static final Color MAP_TITLE_BACK = Color.BLACK;
static final Color DRILL_MAP_DRILL_TOOLS_BACK = Color.BLACK;
static final float DRILL_MAP_DRILL_TOOLS_BACK_OPACITY = 0.8f;
//todo vancharts
private static final Color GANTT_OUT_LINE = GRID_LINE;
private static final FRFont GANTT_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 8, new Color(217, 217, 217));
private static final Color GANTT_BORDER_LINE = new Color(30, 36, 58);
private static final Color GAUGE_TICK = new Color(39, 49, 71);
static final Background BACK = null;
static String COLORS = null;
static {
ChartPreStyleConfig config = ChartPreStyleConfig.getInstance();
try {
DefaultStyleConstants.COLORS = CodeUtils.cjkDecode("\u7ecf\u5178\u9ad8\u4eae");
// 没有经典高亮, 用新特性
if (config.getPreStyle(DefaultStyleConstants.COLORS) == null) {
DefaultStyleConstants.COLORS = CodeUtils.cjkDecode("\u65b0\u7279\u6027");
}
// 没有新特性, 用第一个配色
if (config.getPreStyle(DefaultStyleConstants.COLORS) == null) {
if (config.names().hasNext()) {
String name = GeneralUtils.objectToString(config.names().next());
if (config.getPreStyle(name) != null) {
DefaultStyleConstants.COLORS = name;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

87
designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleHelper4Van.java

@ -0,0 +1,87 @@
package com.fr.van.chart.config;
import com.fr.chart.base.AttrBorder;
import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.DataSheet;
import com.fr.config.predefined.ColorFillStyle;
import com.fr.plugin.chart.PiePlot4VanChart;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import com.fr.plugin.chart.map.VanChartMapPlot;
/**
* @author shine
* @version 10.0
* Created by shine on 2021/10/22
* vanchart的专门写一个因为主体代码 新增y轴 组合图新增图表都要用
*/
public class DefaultStyleHelper4Van {
public static void dealVanPlot(Plot plot) {
if (plot instanceof VanChartPlot) {
VanChartPlot vanChartPlot = (VanChartPlot) plot;
ColorFillStyle colorFillStyle = new ColorFillStyle();
colorFillStyle.setColorStyle(ChartConstants.COLOR_ACC);
colorFillStyle.setFillStyleName(DefaultStyleConstants.COLORS);
AttrFillStyle plotFillStyle = vanChartPlot.getPlotFillStyle();
if (plotFillStyle == null) {
plotFillStyle = new AttrFillStyle();
vanChartPlot.setPlotFillStyle(plotFillStyle);
}
plotFillStyle.setColorFillStyle(colorFillStyle);
if (vanChartPlot.getLegend() != null) {
vanChartPlot.getLegend().setFRFont(DefaultStyleConstants.LEGEND);
}
if (vanChartPlot instanceof VanChartRectanglePlot) {
VanChartRectanglePlot vanChartRectanglePlot = (VanChartRectanglePlot) vanChartPlot;
for (VanChartAxis axis : vanChartRectanglePlot.getXAxisList()) {
dealAxisDefault(axis);
}
for (VanChartAxis axis : vanChartRectanglePlot.getYAxisList()) {
dealAxisDefault(axis);
}
}
dealBorder(vanChartPlot);
DataSheet dataSheet = vanChartPlot.getDataSheet();
dataSheet.getTextAttr().setFRFont(DefaultStyleConstants.DATA_SHEET);
dataSheet.setBorderColor(DefaultStyleConstants.DATA_SHEET_BORDER);
}
}
public static VanChartAxis dealAxisDefault(VanChartAxis axis) {
axis.getTitle().getTextAttr().setFRFont(DefaultStyleConstants.AXIS_TITLE);
axis.getTextAttr().setFRFont(DefaultStyleConstants.AXIS_LABEL);
axis.setAxisColor(DefaultStyleConstants.AXIS_LINE);
axis.setMainGridColor(DefaultStyleConstants.GRID_LINE);
return axis;
}
private static void dealBorder(VanChartPlot vanChartPlot) {
ConditionAttr defaultAttr = vanChartPlot.getConditionCollection().getDefaultAttr();
AttrBorder attrBorder = defaultAttr.getExisted(AttrBorder.class);
if (attrBorder != null) {
attrBorder.setBorderColor(DefaultStyleConstants.BORDER);
attrBorder.setBorderStyle(defaultBorderWidth(vanChartPlot));
}
}
private static int defaultBorderWidth(VanChartPlot vanChartPlot) {
//pie multipie treemap map drillmap heatmap
if (vanChartPlot instanceof PiePlot4VanChart
|| vanChartPlot instanceof VanChartMapPlot) {
return DefaultStyleConstants.SPECIAL_BORDER_WIDTH;
}
return DefaultStyleConstants.BORDER_WIDTH;
}
}

3
designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java

@ -6,13 +6,13 @@ import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.custom.CustomPlotFactory;
import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.plugin.chart.custom.type.CustomPlotType; import com.fr.plugin.chart.custom.type.CustomPlotType;
import com.fr.plugin.chart.custom.type.CustomStyle; import com.fr.plugin.chart.custom.type.CustomStyle;
import com.fr.van.chart.config.DefaultStyleHelper4Van;
import com.fr.van.chart.custom.CustomPlotDesignerPaneFactory; import com.fr.van.chart.custom.CustomPlotDesignerPaneFactory;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -260,6 +260,7 @@ public class VanChartCustomPlotSelectPane extends BasicBeanPane<Chart> {
CustomPlotType customPlotType = selectedPlotTypeList.get(i); CustomPlotType customPlotType = selectedPlotTypeList.get(i);
if (!CustomPlotFactory.customPlotContains(newCustomPlotList, customPlotType)){ if (!CustomPlotFactory.customPlotContains(newCustomPlotList, customPlotType)){
VanChartPlot vanChartPlot = CustomPlotFactory.getCustomPlot(customPlotType); VanChartPlot vanChartPlot = CustomPlotFactory.getCustomPlot(customPlotType);
DefaultStyleHelper4Van.dealVanPlot(vanChartPlot);
vanChartPlot.setCustomType(CustomStyle.CUSTOM.toString()); vanChartPlot.setCustomType(CustomStyle.CUSTOM.toString());
//设置公共属性 //设置公共属性
setCommonAttr(vanChartPlot, customPlot); setCommonAttr(vanChartPlot, customPlot);

7
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java

@ -14,16 +14,17 @@ import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import com.fr.plugin.chart.base.AttrSeriesStackAndAxis; import com.fr.plugin.chart.base.AttrSeriesStackAndAxis;
import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.base.VanChartConstants;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.van.chart.config.DefaultStyleHelper4Van;
import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.designer.style.axis.component.VanChartAxisButtonPane; import com.fr.van.chart.designer.style.axis.component.VanChartAxisButtonPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.awt.BorderLayout;
import java.awt.CardLayout;
/** /**
* 样式-坐标轴界面 * 样式-坐标轴界面
@ -104,6 +105,7 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
List<VanChartAxis> xAxisList = editingPlot.getXAxisList(); List<VanChartAxis> xAxisList = editingPlot.getXAxisList();
VanChartAxis axis = editingPlot.createXAxis(name, VanChartConstants.AXIS_BOTTOM); VanChartAxis axis = editingPlot.createXAxis(name, VanChartConstants.AXIS_BOTTOM);
xAxisList.add(axis); xAxisList.add(axis);
DefaultStyleHelper4Van.dealAxisDefault(axis);
VanChartXYAxisPaneInterface axisPane = initXAxisPane(axis); VanChartXYAxisPaneInterface axisPane = initXAxisPane(axis);
axisPane.populate(axis); axisPane.populate(axis);
@ -119,6 +121,7 @@ public class VanChartAxisPane extends BasicBeanPane<VanChart> {
List<VanChartAxis> yAxisList = editingPlot.getYAxisList(); List<VanChartAxis> yAxisList = editingPlot.getYAxisList();
VanChartAxis axis = editingPlot.createYAxis(name, VanChartConstants.AXIS_LEFT); VanChartAxis axis = editingPlot.createYAxis(name, VanChartConstants.AXIS_LEFT);
yAxisList.add(axis); yAxisList.add(axis);
DefaultStyleHelper4Van.dealAxisDefault(axis);
VanChartXYAxisPaneInterface axisPane = initYAxisPane(axis); VanChartXYAxisPaneInterface axisPane = initYAxisPane(axis);
axisPane.populate(axis); axisPane.populate(axis);

9
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisScrollPaneWithTypeSelect.java

@ -1,15 +1,16 @@
package com.fr.van.chart.designer.style.axis; package com.fr.van.chart.designer.style.axis;
import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Axis;
import com.fr.design.i18n.Toolkit;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartTimeAxis; import com.fr.plugin.chart.attr.axis.VanChartTimeAxis;
import com.fr.plugin.chart.attr.axis.VanChartValueAxis; import com.fr.plugin.chart.attr.axis.VanChartValueAxis;
import com.fr.plugin.chart.type.AxisType; import com.fr.plugin.chart.type.AxisType;
import com.fr.van.chart.config.DefaultStyleHelper4Van;
import com.fr.van.chart.designer.AbstractVanChartScrollPane; import com.fr.van.chart.designer.AbstractVanChartScrollPane;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.VanChartStylePane;
@ -83,9 +84,9 @@ public class VanChartAxisScrollPaneWithTypeSelect extends AbstractVanChartScroll
public void populate(VanChartAxis axis){ public void populate(VanChartAxis axis){
AxisType axisType = axis.getAxisType(); AxisType axisType = axis.getAxisType();
textAxisPane.populateBean(new VanChartAxis(axis.getAxisName(), axis.getPosition())); textAxisPane.populateBean(DefaultStyleHelper4Van.dealAxisDefault(new VanChartAxis(axis.getAxisName(), axis.getPosition())));
timeAxisPane.populateBean(new VanChartTimeAxis(axis.getAxisName(), axis.getPosition())); timeAxisPane.populateBean(DefaultStyleHelper4Van.dealAxisDefault(new VanChartTimeAxis(axis.getAxisName(), axis.getPosition())));
valueAxisPane.populateBean(new VanChartValueAxis(axis.getAxisName(), axis.getPosition())); valueAxisPane.populateBean(DefaultStyleHelper4Van.dealAxisDefault(new VanChartValueAxis(axis.getAxisName(), axis.getPosition())));
if(ComparatorUtils.equals(axisType, AxisType.AXIS_CATEGORY)){ if(ComparatorUtils.equals(axisType, AxisType.AXIS_CATEGORY)){
textAxisPane.populateBean(axis); textAxisPane.populateBean(axis);
} else if(ComparatorUtils.equals(axisType, AxisType.AXIS_TIME)){ } else if(ComparatorUtils.equals(axisType, AxisType.AXIS_TIME)){

Loading…
Cancel
Save