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

Loading…
Cancel
Save