Browse Source

update

master
Fangjie Hu 8 years ago
parent
commit
a128fcfb1c
  1. 12
      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

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

@ -5,12 +5,12 @@ import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGlyph;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.base.ChartConstants;
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.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;
@ -32,7 +32,7 @@ import java.util.List;
* 类说明: 事件说明: 工具栏编辑--> 是刷新ChartComponent 然后响应整个设计块的改变事件
右键编辑 ---> 刷新ChartCompment 刷新对应的工具栏(加入事件) 然后响应整个设计块的改变事件
*/
public class ChartComponent extends MiddleChartComponent implements MouseListener, MouseMotionListener{
public class ChartComponent extends MiddleChartComponent implements MouseListener, MouseMotionListener, CallbackEvent{
private static final long serialVersionUID = 744164838619052097L;
private final List<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
private ChartCollection chartCollection4Design;
@ -315,9 +315,13 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
//不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单
//其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边
//处理画图事件
Image chartImage = ChartGlyphToImageManager.toImage(this, chartGlyph, chartWidth, chartHeight, ScreenResolution.getScreenResolution());
//Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution());
Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution(), this);
g2d.drawImage(chartImage, 0, 0, null);
}
}
@Override
public void callback() {
this.repaint();
}
}

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

@ -1,43 +0,0 @@
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

@ -1,23 +0,0 @@
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