Browse Source

Pull request #2560: *CHART-15566 预定义边界界面图表预览

Merge in DESIGN/design from ~BJORN/design:feature/10.0 to feature/10.0

* commit 'd386311d92329e945e051c09c75adf2c0c951ca6':
  CHART-15566 预定义边界界面图表预览
  Revert "无JIRA任务 修复feature"
  无JIRA任务 修复feature
persist/11.0
Bjorn 4 years ago
parent
commit
1df4bba463
  1. 4
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java
  3. 6
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java
  4. 100
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java
  5. 109
      designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java
  6. 6
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  7. 21
      designer-realize/src/main/java/com/fr/grid/GridUI.java

4
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleBlock.java

@ -96,7 +96,7 @@ public class PredefinedStyleBlock extends JPanel {
private void initPane(boolean supportEdit) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
PredefinedStylePreviewPane content = new PredefinedStylePreviewPane(0.387, 0.384);
content.setPreferredSize(new Dimension(200, 125));
content.setPreferredSize(new Dimension(200, 180));
UILabel label = new UILabel(previewObject.getStyleName());
label.setToolTipText(previewObject.getStyleName());
label.setPreferredSize(new Dimension(167, 25));
@ -111,7 +111,7 @@ public class PredefinedStyleBlock extends JPanel {
this.add(content, BorderLayout.CENTER);
this.add(panel, BorderLayout.SOUTH);
this.setPreferredSize(new Dimension(200, 150));
this.setPreferredSize(new Dimension(200, 210));
panel.setBackground(Color.WHITE);
this.setBackground(Color.WHITE);
content.refresh(this.previewObject);

2
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleEditPane.java

@ -94,7 +94,7 @@ public class PredefinedStyleEditPane extends AbstractAttrNoScrollPane {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel titlePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Predefined_Overall_Preview"));
previewPane = new PredefinedStylePreviewPane();
previewPane.setPreferredSize(new Dimension(517, 320));
previewPane.setPreferredSize(new Dimension(517, 500));
titlePane.add(previewPane);
jPanel.add(titlePane, BorderLayout.CENTER);

6
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/PredefinedStyleSelectPane.java

@ -1,7 +1,7 @@
package com.fr.design.mainframe.predefined.ui;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.config.ServerPreferenceConfig;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.ChangeListener;
import com.fr.design.gui.icontainer.UIScrollPane;
@ -9,9 +9,9 @@ import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.util.Iterator;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Iterator;
/**
* Created by kerry on 2020-08-26
@ -51,7 +51,7 @@ public class PredefinedStyleSelectPane extends BasicPane {
contentPane.removeAll();
Iterator<PredefinedStyle> iterator = ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getPredefinedStyleIterator();
int rowCount = (ServerPreferenceConfig.getInstance().getPreferenceStyleConfig().getPredefinedSize() +2)/ 3;
contentPane.setPreferredSize(new Dimension(618, 157 * rowCount));
contentPane.setPreferredSize(new Dimension(618, 210 * rowCount));
while (iterator.hasNext()) {
PredefinedStyle tmpStyle = iterator.next();

100
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/ChartPreStylePreView.java

@ -0,0 +1,100 @@
package com.fr.design.mainframe.predefined.ui.preview;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartPainter;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.base.ChartPreStyleProvider;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.script.Calculator;
import com.fr.stable.core.PropertyChangeListener;
import java.util.List;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-09-28
*/
public class ChartPreStylePreView extends MiddleChartComponent {
private ChartCollection chartCollection;
private double scaleX = 1.0;
private double scaleY = 1.0;
private CallbackEvent callbackEvent;
public ChartPreStylePreView() {
}
public ChartPreStylePreView(ChartCollection cc) {
this(cc, 1.0, 1.0);
}
public ChartPreStylePreView(ChartCollection cc, double scaleX, double scaleY) {
this.scaleX = scaleX;
this.scaleY = scaleY;
populate(cc);
}
public void setCallbackEvent(CallbackEvent callbackEvent) {
this.callbackEvent = callbackEvent;
}
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.translate(ChartConstants.PREGAP4BOUNDS / 2, ChartConstants.PREGAP4BOUNDS / 2);
g2d.scale(scaleX, scaleY);
super.paintComponent(g);
drawChart(g2d);
g2d.scale(1 / scaleX, 1 / scaleY);
g2d.translate(-ChartConstants.PREGAP4BOUNDS / 2, -ChartConstants.PREGAP4BOUNDS / 2);
}
private void drawChart(Graphics2D g2d) {
Dimension d = getBounds().getSize();
int chartWidth = (int) (d.width / scaleX) - ChartConstants.PREGAP4BOUNDS;
int chartHeight = (int) (d.height / scaleX) - ChartConstants.PREGAP4BOUNDS;
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight);
painter.paint(g2d, chartWidth, chartHeight, 0, null, callbackEvent);
}
public void refresh(PredefinedStyle style) {
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class);
List<ChartPreStyleProvider> chartPreStyleProviders = vanChart.getChartPreStyleProvider();
for (ChartPreStyleProvider chartPreStyleProvider : chartPreStyleProviders) {
chartPreStyleProvider.updatePreDefinedStyle(style);
}
vanChart.attrChange();
}
@Override
public void populate(BaseChartCollection cc) {
this.chartCollection = (ChartCollection) cc;
}
@Override
public BaseChartCollection update() {
return this.chartCollection;
}
@Override
public void addStopEditingListener(PropertyChangeListener l) {
}
@Override
public void reset() {
}
}

109
designer-base/src/main/java/com/fr/design/mainframe/predefined/ui/preview/PredefinedStylePreviewPane.java

@ -1,26 +1,51 @@
package com.fr.design.mainframe.predefined.ui.preview;
import com.fr.base.background.ColorBackground;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Title;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.config.predefined.PredefinedStyle;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.ComponentUtils;
import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.AttrLabel;
import com.fr.plugin.chart.base.VanChartTools;
import com.fr.plugin.chart.column.VanChartColumnPlot;
import com.fr.plugin.chart.line.VanChartLinePlot;
import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.Constants;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
/**
* Created by kerry on 2020-09-06
*/
public class PredefinedStylePreviewPane extends StyleSettingPreviewPane {
public class PredefinedStylePreviewPane extends StyleSettingPreviewPane implements CallbackEvent {
private ElementCasePreview elementCasePreview;
private Background background;
private double scaleX = 1.0;
private double scaleY = 1.0;
private ChartPreStylePreView columnChartPane;
private ChartPreStylePreView lineChartPane;
private int COLUMN_CHART_WIDTH = 297;
private int COLUMN_CHART_HEIGHT = 220;
public static final double CHART_SCALE = 0.6;
public PredefinedStylePreviewPane() {
this(1.0, 1.0);
@ -31,10 +56,74 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane {
this.scaleY = scaleY;
this.setBackground(Color.WHITE);
this.elementCasePreview = new ElementCasePreview();
this.elementCasePreview.setPreferredSize(new Dimension(517, 320));
this.add(initChartPreViewPane());
this.elementCasePreview.setPreferredSize(new Dimension(517, 250));
this.add(this.elementCasePreview);
}
private JPanel initChartPreViewPane() {
columnChartPane = new ChartPreStylePreView(initVanColumnChart(), CHART_SCALE, CHART_SCALE);
columnChartPane.setPreferredSize(new Dimension(COLUMN_CHART_WIDTH, COLUMN_CHART_HEIGHT));
columnChartPane.setCallbackEvent(this);
lineChartPane = new ChartPreStylePreView(initVanLineChart(), CHART_SCALE, CHART_SCALE);
lineChartPane.setPreferredSize(new Dimension(220, 220));
lineChartPane.setCallbackEvent(this);
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(columnChartPane);
panel.add(lineChartPane);
return panel;
}
//柱形图
private ChartCollection initVanColumnChart() {
try {
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID)[0].clone();
chart.getTitle().setPosition(Constants.LEFT);
VanChartTools vanChartTools = chart.getVanChartTools();
vanChartTools.setSort(false);
vanChartTools.setExport(false);
vanChartTools.setFullScreen(false);
VanChartPlot plot = chart.getPlot();
AttrLabel defaultAttrLabel = plot.getDefaultAttrLabel();
defaultAttrLabel.setEnable(true);
defaultAttrLabel.getAttrLabelDetail().getBorder().setBorderStyle(0);
defaultAttrLabel.getAttrLabelDetail().getBackground().setBackground(null);
plot.getConditionCollection().getDefaultAttr().addDataSeriesCondition(defaultAttrLabel);
plot.getLegend().setLegendVisible(false);
plot.getDataSheet().setVisible(true);
ChartCollection chartCollection = new ChartCollection(chart);
return chartCollection;
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return null;
}
//折线图
private ChartCollection initVanLineChart() {
try {
VanChart chart = (VanChart) ChartTypeManager.getInstance().getCharts(VanChartLinePlot.VAN_CHART_LINE_PLOT)[0].clone();
chart.getTitle().setPosition(Constants.LEFT);
VanChartTools vanChartTools = chart.getVanChartTools();
vanChartTools.setSort(false);
vanChartTools.setExport(false);
vanChartTools.setFullScreen(false);
VanChartLinePlot plot = chart.getPlot();
plot.getLegend().setPosition(Constants.TOP);
VanChartAxis defaultXAxis = plot.getDefaultXAxis();
Title title = new Title();
title.setTextObject(Toolkit.i18nText("Fine-Design_Chart_Category"));
defaultXAxis.setTitle(title);
defaultXAxis.setShowAxisTitle(true);
ChartCollection chartCollection = new ChartCollection(chart);
return chartCollection;
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
return null;
}
@Override
public void refresh() {
@ -50,10 +139,14 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane {
if (background == null) {
background = ColorBackground.getInstance(Color.WHITE);
}
background.paint(g, new Rectangle2D.Double(0, 0, 517, 320));
background.paint(g, new Rectangle2D.Double(0, 0, 517, 500));
this.columnChartPane.paintComponent(g);
g.translate(COLUMN_CHART_WIDTH, 0);
this.lineChartPane.paintComponent(g);
g.translate(-COLUMN_CHART_WIDTH, COLUMN_CHART_HEIGHT + 10);
this.elementCasePreview.paintContent(g);
g.translate(0, -COLUMN_CHART_HEIGHT - 10);
// 恢复双缓冲
ComponentUtils.resetBuffer(dbcomponents);
@ -73,8 +166,14 @@ public class PredefinedStylePreviewPane extends StyleSettingPreviewPane {
public void refresh(PredefinedStyle style, boolean displayFormBackground) {
elementCasePreview.refresh(style);
columnChartPane.refresh(style);
lineChartPane.refresh(style);
background = displayFormBackground ? style.getFormBackground().getBackground() : style.getReportBackground();
this.repaint();
}
@Override
public void callback() {
this.repaint();
}
}

6
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -7,6 +7,7 @@ import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.log.FineLoggerFactory;
@ -144,6 +145,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
return;
}
chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false);
Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint();
@ -268,4 +270,8 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public void callback() {
this.repaint();
}
private String getGlobalPredefinedStyleName() {
return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
}
}

21
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -9,6 +9,7 @@ import com.fr.base.PaperSize;
import com.fr.base.Utils;
import com.fr.base.background.ColorBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants;
@ -45,16 +46,19 @@ import com.fr.report.stable.ReportConstants;
import com.fr.report.stable.ReportSettings;
import com.fr.report.worksheet.FormElementCase;
import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.AssistUtils;
import com.fr.stable.ColumnRow;
import com.fr.stable.Constants;
import com.fr.stable.script.CalculatorUtils;
import com.fr.stable.unit.FU;
import com.fr.stable.AssistUtils;
import com.fr.third.antlr.ANTLRException;
import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
@ -72,9 +76,6 @@ import java.awt.geom.Line2D;
import java.awt.geom.Line2D.Double;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class GridUI extends ComponentUI {
@ -184,8 +185,8 @@ public class GridUI extends ComponentUI {
}
}
private String getGlobalPredefinedStyleName(){
return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
private String getGlobalPredefinedStyleName() {
return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplatePredefinedStyle();
}
private void clearBackground(Graphics2D g2d, Grid grid) {
@ -308,7 +309,7 @@ public class GridUI extends ComponentUI {
private int resolution;
private static final double THRESHOLD = 1.0E-4D;
private static final double THRESHOLD = 1.0E-4D;
DrawLineHelper(int startIndex, int endIndex, boolean showGridLine,
boolean showPaginateLine, DynamicUnitList sizeList, double paperPaintSize,
@ -512,6 +513,9 @@ public class GridUI extends ComponentUI {
if (tmpCellElement.getStyle() instanceof NameStyle) {
((NameStyle) tmpCellElement.getStyle()).setPredefinedStyleName(getGlobalPredefinedStyleName());
}
if (tmpCellElement.getValue() instanceof BaseChartCollection) {
((BaseChartCollection) tmpCellElement.getValue()).setPredefinedStyleName(getGlobalPredefinedStyleName(), false);
}
// denny_Grid: 画Grid中单元格的内容(包括单元格的背景Content + Background), 不包括边框
painter.paintBackground(g2d, report, tmpCellElement, cellWidth - 1, cellHeight - 1);
@ -958,6 +962,9 @@ public class GridUI extends ComponentUI {
g2d.translate(floatX, floatY);
if (tmpFloatElement.getValue() instanceof BaseChartCollection) {
((BaseChartCollection) tmpFloatElement.getValue()).setPredefinedStyleName(getGlobalPredefinedStyleName(), false);
}
PaintUtils.paintFloatElement(g2d, tmpFloatElement,
tmpFloatElement.getWidth().toPixI(resolution),
tmpFloatElement.getHeight().toPixI(resolution), resolution);

Loading…
Cancel
Save