Browse Source

update

master
Fangjie Hu 8 years ago
parent
commit
ec1201808f
  1. 4
      designer_chart/src/com/fr/design/chart/gui/ChartComponent.java
  2. 43
      designer_chart/src/com/fr/design/chart/gui/chartimage/ChartGlyphToImageEvent.java
  3. 23
      designer_chart/src/com/fr/design/chart/gui/chartimage/ChartGlyphToImageManager.java

4
designer_chart/src/com/fr/design/chart/gui/ChartComponent.java

@ -10,7 +10,7 @@ import com.fr.chart.chartattr.Axis;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartglyph.AxisGlyph;
import com.fr.chart.chartimage.ChartGlyphToImageManager;
import com.fr.design.chart.gui.chartimage.ChartGlyphToImageManager;
import com.fr.design.chart.gui.active.ActiveGlyph;
import com.fr.design.chart.gui.active.ChartActiveGlyph;
import com.fr.design.gui.chart.MiddleChartComponent;
@ -315,7 +315,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
//不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单
//其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边
//处理画图事件
Image chartImage = ChartGlyphToImageManager.toImage(g2d, chartGlyph, chartWidth, chartHeight, ScreenResolution.getScreenResolution());
Image chartImage = ChartGlyphToImageManager.toImage(this, chartGlyph, chartWidth, chartHeight, ScreenResolution.getScreenResolution());
//Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution());
g2d.drawImage(chartImage, 0, 0, null);
}

43
designer_chart/src/com/fr/design/chart/gui/chartimage/ChartGlyphToImageEvent.java

@ -0,0 +1,43 @@
package com.fr.design.chart.gui.chartimage;
import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.chartdata.CallbackEvent;
import java.awt.*;
/**
* Created by hufan on 2016/10/18.
*/
public class ChartGlyphToImageEvent implements CallbackEvent<Image> {
private Component painter;
private BaseChartGlyph glyph;
private int width;
private int height;
private int resolution;
private Image image;
public ChartGlyphToImageEvent() {
}
public ChartGlyphToImageEvent(Component painter) {
this.painter = painter;
}
public ChartGlyphToImageEvent setImageArgs(BaseChartGlyph glyph, int width, int height, int resolution){
this.glyph = glyph;
this.width = width;
this.height = height;
this.resolution = resolution;
return this;
}
public Image run() {
glyph.addChartDataEvent(this);
this.image = glyph.toImage(width, height, resolution);
return image;
}
public void callback() {
painter.repaint();
}
}

23
designer_chart/src/com/fr/design/chart/gui/chartimage/ChartGlyphToImageManager.java

@ -0,0 +1,23 @@
package com.fr.design.chart.gui.chartimage;
import com.fr.base.chart.BaseChartGlyph;
import java.awt.*;
/**
* Created by hufan on 2016/10/18.
*/
public class ChartGlyphToImageManager {
private static ChartGlyphToImageManager toImageManager = new ChartGlyphToImageManager();
public static Image toImage(Component listener, BaseChartGlyph glyph, int width, int height, int resolution){
//初始化新的图片处理
ChartGlyphToImageEvent imageEvent = toImageManager.initImageEvent(listener);
//获取图片
return imageEvent.setImageArgs(glyph, width, height, resolution).run();
}
private ChartGlyphToImageEvent initImageEvent(Component listener){
return new ChartGlyphToImageEvent(listener);
}
}
Loading…
Cancel
Save