Browse Source

REPORT-63505 图表进入编辑状态后创建组件预览图不渲染图表

zheng-1641779399395
Tommy 3 years ago
parent
commit
b28939592e
  1. 15
      designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java

15
designer-form/src/main/java/com/fr/design/mainframe/share/action/CreateComponentAction.java

@ -10,7 +10,9 @@ import com.fr.data.impl.NameTableData;
import com.fr.data.impl.TableDataDictionary; import com.fr.data.impl.TableDataDictionary;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.designer.creator.XChartEditor;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
@ -33,6 +35,7 @@ import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.DataControl; import com.fr.form.ui.DataControl;
import com.fr.form.ui.DictionaryContainer; import com.fr.form.ui.DictionaryContainer;
import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -56,6 +59,7 @@ import javax.swing.Action;
import javax.swing.UIManager; import javax.swing.UIManager;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.Rectangle; import java.awt.Rectangle;
@ -253,6 +257,17 @@ public class CreateComponentAction extends UpdateAction {
BufferedImage im = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_ARGB); BufferedImage im = new BufferedImage((int) rect.getWidth(), (int) rect.getHeight(), BufferedImage.TYPE_INT_ARGB);
comp.paint(im.getGraphics()); comp.paint(im.getGraphics());
if (comp instanceof XWTitleLayout) {
XCreator body = ((XWTitleLayout) comp).getBodyCreator();
if (body instanceof XChartEditor) {
XChartEditor chartEditor = (XChartEditor) body;
Dimension size = chartEditor.getSize();
BufferedImage chartImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
PaddingMargin margin = chartEditor.toData().getMargin();
chartEditor.getDesignerEditor().paintEditor(chartImage.getGraphics(), size, margin);
im.getGraphics().drawImage(chartImage, 0, chartEditor.getY(), null);
}
}
return im; return im;
} }

Loading…
Cancel
Save