|
|
@ -1,8 +1,13 @@ |
|
|
|
package com.fr.design.chart; |
|
|
|
package com.fr.design.chart; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.GraphHelper; |
|
|
|
import com.fr.base.chart.BaseChartPainter; |
|
|
|
import com.fr.general.IOUtils; |
|
|
|
import com.fr.base.chart.chartdata.CallbackEvent; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
import com.fr.base.chart.result.WebChartIDInfo; |
|
|
|
|
|
|
|
import com.fr.chart.chartattr.Chart; |
|
|
|
|
|
|
|
import com.fr.chart.chartattr.ChartCollection; |
|
|
|
|
|
|
|
import com.fr.design.ChartTypeInterfaceManager; |
|
|
|
|
|
|
|
import com.fr.design.file.HistoryTemplateListCache; |
|
|
|
|
|
|
|
import com.fr.script.Calculator; |
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
import com.fr.stable.xml.XMLPrintWriter; |
|
|
|
import com.fr.stable.xml.XMLable; |
|
|
|
import com.fr.stable.xml.XMLable; |
|
|
|
import com.fr.stable.xml.XMLableReader; |
|
|
|
import com.fr.stable.xml.XMLableReader; |
|
|
@ -13,7 +18,6 @@ import java.awt.Component; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
import java.awt.Paint; |
|
|
|
import java.awt.Paint; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 图表的缩略图Icon, 在选择图表类型界面 用到. |
|
|
|
* 图表的缩略图Icon, 在选择图表类型界面 用到. |
|
|
@ -21,21 +25,47 @@ import java.awt.image.BufferedImage; |
|
|
|
public class ChartIcon implements Icon, XMLable { |
|
|
|
public class ChartIcon implements Icon, XMLable { |
|
|
|
private static final int WIDTH = 400; |
|
|
|
private static final int WIDTH = 400; |
|
|
|
private static final int HEIGHT = 225; |
|
|
|
private static final int HEIGHT = 225; |
|
|
|
/** |
|
|
|
|
|
|
|
* 缩略图中的图片路径 |
|
|
|
|
|
|
|
*/ |
|
|
|
private ChartCollection chartCollection; |
|
|
|
private String imagePath; |
|
|
|
private CallbackEvent callbackEvent; |
|
|
|
|
|
|
|
|
|
|
|
private String chartName; |
|
|
|
private String chartName; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 构造Chart的缩略图Icon |
|
|
|
* 构造Chart的缩略图Icon |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ChartIcon(String imagePath, String chartName) { |
|
|
|
public ChartIcon(ChartCollection chartCollection) { |
|
|
|
this.imagePath = imagePath; |
|
|
|
this.chartCollection = chartCollection; |
|
|
|
|
|
|
|
initChartName(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ChartCollection getChartCollection() { |
|
|
|
|
|
|
|
return chartCollection; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getChartName() { |
|
|
|
|
|
|
|
return chartName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setChartCollection(ChartCollection chartCollection) { |
|
|
|
|
|
|
|
this.chartCollection = chartCollection; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setChartName(String chartName) { |
|
|
|
this.chartName = chartName; |
|
|
|
this.chartName = chartName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initChartName() { |
|
|
|
|
|
|
|
Chart chart = chartCollection.getSelectedChart(Chart.class); |
|
|
|
|
|
|
|
String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID()); |
|
|
|
|
|
|
|
chartName = subName[0]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void registerCallBackEvent(CallbackEvent callbackEvent) { |
|
|
|
|
|
|
|
this.callbackEvent = callbackEvent; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 画出缩略图Icon |
|
|
|
* 画出缩略图Icon |
|
|
|
* |
|
|
|
* |
|
|
@ -47,21 +77,29 @@ public class ChartIcon implements Icon, XMLable { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) { |
|
|
|
public void paintIcon(Component c, Graphics g, int x, int y) { |
|
|
|
|
|
|
|
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
BaseChartPainter chartPainter = getChartPainter(); |
|
|
|
|
|
|
|
|
|
|
|
Paint oldPaint = g2d.getPaint(); |
|
|
|
int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
|
|
|
|
Paint oldPaint = g2d.getPaint(); |
|
|
|
g.translate(x, y); |
|
|
|
g.translate(x, y); |
|
|
|
g2d.setPaint(Color.white); |
|
|
|
g2d.setPaint(Color.white); |
|
|
|
|
|
|
|
|
|
|
|
g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); |
|
|
|
g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); |
|
|
|
BufferedImage demoImage = IOUtils.readImageWithCache(imagePath); |
|
|
|
|
|
|
|
GraphHelper.paintImage(g, getIconWidth(), getIconHeight(), demoImage, Constants.IMAGE_ADJUST, Constants.NULL, Constants.NULL, -1, -1); |
|
|
|
chartPainter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent); |
|
|
|
|
|
|
|
|
|
|
|
g.translate(-x, -y); |
|
|
|
g.translate(-x, -y); |
|
|
|
g2d.setPaint(oldPaint); |
|
|
|
g2d.setPaint(oldPaint); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected BaseChartPainter getChartPainter() { |
|
|
|
|
|
|
|
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), |
|
|
|
|
|
|
|
WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight()); |
|
|
|
|
|
|
|
return painter; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 返回缩略图的宽度 |
|
|
|
* 返回缩略图的宽度 |
|
|
|
* |
|
|
|
* |
|
|
@ -83,20 +121,6 @@ public class ChartIcon implements Icon, XMLable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 返回缩略图中的图片路径 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return 缩略图中的图片路径 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public String getImagePath() { |
|
|
|
|
|
|
|
return imagePath; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getChartName() { |
|
|
|
|
|
|
|
return chartName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void readXML(XMLableReader reader) { |
|
|
|
public void readXML(XMLableReader reader) { |
|
|
|
//do nothing
|
|
|
|
//do nothing
|
|
|
@ -114,8 +138,11 @@ public class ChartIcon implements Icon, XMLable { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Object clone() throws CloneNotSupportedException { |
|
|
|
public Object clone() throws CloneNotSupportedException { |
|
|
|
ChartIcon cloned = (ChartIcon) super.clone(); |
|
|
|
ChartIcon cloned = (ChartIcon) super.clone(); |
|
|
|
cloned.imagePath = this.imagePath; |
|
|
|
if (getChartCollection() != null) { |
|
|
|
cloned.chartName = this.chartName; |
|
|
|
cloned.setChartCollection(this.getChartCollection()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cloned.setChartName(this.getChartName()); |
|
|
|
|
|
|
|
; |
|
|
|
return cloned; |
|
|
|
return cloned; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|