Fangjie Hu
8 years ago
3 changed files with 68 additions and 2 deletions
@ -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(); |
||||
} |
||||
} |
@ -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…
Reference in new issue