Browse Source

Merge pull request #1082 in DESIGN/design from ~ZHENG/c-design:compatibleVan to feature/10.0

* commit 'd0867aaef1d78232ee8ee4181cbeb5afe5308afd':
  CHART-10225 表单设计器 图表渲染
research/11.0
zheng 5 years ago
parent
commit
5c445be3d1
  1. 3
      designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java
  2. 26
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  3. 2
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java

3
designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java

@ -1,7 +1,6 @@
package com.fr.design.gui.chart; package com.fr.design.gui.chart;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.stable.core.PropertyChangeListener; import com.fr.stable.core.PropertyChangeListener;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -18,7 +17,5 @@ public abstract class MiddleChartComponent extends JComponent {
public abstract void reset(); public abstract void reset();
public abstract ChartProvider getEditingChart();
public abstract void addStopEditingListener(PropertyChangeListener list); public abstract void addStopEditingListener(PropertyChangeListener list);
} }

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

@ -2,21 +2,21 @@ package com.fr.design.chart.gui;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartPainter;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.ChartWebPara; import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartConstants;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.script.Calculator;
import com.fr.stable.core.PropertyChangeListener; import com.fr.stable.core.PropertyChangeListener;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Paint; import java.awt.Paint;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -35,7 +35,6 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
private static final long serialVersionUID = 744164838619052097L; private static final long serialVersionUID = 744164838619052097L;
private final List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>(); private final List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
private ChartCollection chartCollection4Design; private ChartCollection chartCollection4Design;
private ChartProvider editingChart;
private int chartWidth = -1; private int chartWidth = -1;
private int chartHeight = -1; private int chartHeight = -1;
@ -91,11 +90,8 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public void reset() { public void reset() {
fireStopEditing(); fireStopEditing();
this.editingChart = null;
this.chartHeight = this.chartWidth = -1; this.chartHeight = this.chartWidth = -1;
this.editingChart = this.chartCollection4Design.getSelectedChartProvider();
refreshChartGlyph(); refreshChartGlyph();
repaint(); repaint();
@ -138,11 +134,6 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
return (this.chartCollection4Design == null) ? 0 : this.chartCollection4Design.getChartCount(); return (this.chartCollection4Design == null) ? 0 : this.chartCollection4Design.getChartCount();
} }
public ChartProvider getEditingChart() {
return editingChart;
}
public void paintComponent(Graphics g) { // public void paintComponent(Graphics g) { //
super.paintComponent(g); super.paintComponent(g);
@ -180,7 +171,6 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
*/ */
private void refreshChartGlyph() { private void refreshChartGlyph() {
Dimension d = getBounds().getSize(); Dimension d = getBounds().getSize();
this.editingChart = this.chartCollection4Design.getSelectedChartProvider();// kunsnat: 切换选中时 同步切换Plot
this.chartWidth = d.width - ChartConstants.PREGAP4BOUNDS; this.chartWidth = d.width - ChartConstants.PREGAP4BOUNDS;
this.chartHeight = d.height - ChartConstants.PREGAP4BOUNDS; this.chartHeight = d.height - ChartConstants.PREGAP4BOUNDS;
} }
@ -240,20 +230,20 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
} }
private boolean needRefreshChartGlyph() { private boolean needRefreshChartGlyph() {
return editingChart == null || chartWidth != this.getBounds().width || chartHeight != this.getBounds().height; return chartWidth != this.getBounds().width || chartHeight != this.getBounds().height;
} }
private void drawChart(Graphics2D g2d) { private void drawChart(Graphics2D g2d) {
if (editingChart != null) { if (chartCollection4Design != null) {
BaseChartPainter painter = chartCollection4Design.createResultChartPainter(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight);
int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
if (resolution == 0){ if (resolution == 0){
resolution = ScreenResolution.getScreenResolution(); resolution = ScreenResolution.getScreenResolution();
} }
Image chartImage = editingChart.toImage(chartWidth, chartHeight, resolution, new ChartWebPara()); painter.paint(g2d, chartWidth, chartHeight, resolution, null);
g2d.drawImage(chartImage, 0, 0, null);
} }
} }

2
designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java

@ -37,7 +37,7 @@ public class ChartWidgetOption extends WidgetOption {
Class<? extends ChartEditor> clz = widgetClass(); Class<? extends ChartEditor> clz = widgetClass();
try { try {
ChartEditor widget = clz.newInstance(); ChartEditor widget = clz.newInstance();
widget.setChartCollection(BaseChartGetter.createChartCollection(this.chartID)); widget.resetChangeChartCollection(BaseChartGetter.createChartCollection(this.chartID));
return widget; return widget;
} catch (InstantiationException e) { } catch (InstantiationException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);

Loading…
Cancel
Save