Browse Source

REPORT-51992 设计器性能提升-缩略图占内存优化

feature/10.0
Henry.Wang 4 years ago
parent
commit
c69fefe8e7
  1. 2
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 63
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  3. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  4. 3
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

2
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -298,7 +298,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData(); WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData();
fix(creator,creator.getX(),creator.getY()); fix(creator,creator.getX(),creator.getY());
wabs.setBounds(creator.toData(),creator.getBounds()); wabs.setBounds(creator.toData(),creator.getBounds());
XElementCase.updateECImage(creator);
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator); layout.updateBoundsWidget(creator);
} }

63
designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java

@ -32,16 +32,16 @@ import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
import java.util.Set; import java.util.Set;
public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider{ public class XElementCase extends XBorderStyleWidgetCreator implements FormElementCaseContainerProvider {
private UILabel imageLable; private UILabel imageLable;
private FormDesigner designer; private FormDesigner designer;
private static BufferedImage DEFAULT_BACKGROUND; private static BufferedImage DEFAULT_BACKGROUND;
private boolean isHovering = false; private boolean isHovering = false;
static{ static {
try{ try {
DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase.png"); DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase.png");
}catch (Throwable e) { } catch (Throwable e) {
//IBM jdk 1.5.0_22 并发下读取图片有时会异常(EOFException), 这个图片反正只有设计器用到, 捕获住 //IBM jdk 1.5.0_22 并发下读取图片有时会异常(EOFException), 这个图片反正只有设计器用到, 捕获住
DEFAULT_BACKGROUND = CoreGraphHelper.createBufferedImage(0, 0); DEFAULT_BACKGROUND = CoreGraphHelper.createBufferedImage(0, 0);
} }
@ -110,7 +110,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
} }
public CRPropertyDescriptor[] getExtraTableEditor(){ public CRPropertyDescriptor[] getExtraTableEditor() {
CRPropertyDescriptor[] extraTableEditor = resolveCompatible(); CRPropertyDescriptor[] extraTableEditor = resolveCompatible();
CRPropertyDescriptor reportFitEditor = getReportFitEditor(); CRPropertyDescriptor reportFitEditor = getReportFitEditor();
if (reportFitEditor == null) { if (reportFitEditor == null) {
@ -134,7 +134,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
editor.setReportFitAttr(null); editor.setReportFitAttr(null);
} }
ReportFitAttr reportFit = editor.getReportFitAttr(); ReportFitAttr reportFit = editor.getReportFitAttr();
if(fitAttr != null){ if (fitAttr != null) {
reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr; reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr;
} }
ReportFitAttr reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit; ReportFitAttr reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit;
@ -200,7 +200,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
/** /**
* 从data中获取到图片背景, 并设置到Label上 * 从data中获取到图片背景, 并设置到Label上
*/ */
private UILabel initImageBackground(){ private UILabel initImageBackground() {
UILabel imageLable = new UILabel(); UILabel imageLable = new UILabel();
BufferedImage image = toData().getECImage(); BufferedImage image = toData().getECImage();
if (image == null) { if (image == null) {
@ -214,7 +214,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
/** /**
* 设置指定Label的背景 * 设置指定Label的背景
*/ */
private void setLabelBackground(Image image, UILabel imageLable){ private void setLabelBackground(Image image, UILabel imageLable) {
ImageIcon icon = new ImageIcon(image); ImageIcon icon = new ImageIcon(image);
imageLable.setIcon(icon); imageLable.setIcon(icon);
imageLable.setOpaque(true); imageLable.setOpaque(true);
@ -223,7 +223,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
} }
@Override @Override
public void paintBorder(Graphics g, Rectangle bounds){ public void paintBorder(Graphics g, Rectangle bounds) {
if (!isHovering) { if (!isHovering) {
super.paintBorder(g, bounds); super.paintBorder(g, bounds);
} }
@ -250,7 +250,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* 该组件是否可以拖入参数面板 * 该组件是否可以拖入参数面板
* @return 是则返回true * @return 是则返回true
*/ */
public boolean canEnterIntoParaPane(){ public boolean canEnterIntoParaPane() {
return false; return false;
} }
@ -274,16 +274,35 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
toData().setElementCase(el); toData().setElementCase(el);
} }
public void setBackground(BufferedImage image){ public void setBackground(BufferedImage image) {
toData().setECImage(image); toData().getElementCaseImage().adjustImageBytes(image);
setEditorIcon(image); setEditorIcon(toData().getECImage() == null ? DEFAULT_BACKGROUND : toData().getECImage());
} }
private void setEditorIcon(BufferedImage image){ public static void updateECImage(XCreator creator) {
if (creator instanceof XWTitleLayout) {
XWTitleLayout xwTitleLayout = (XWTitleLayout) creator;
for (int i = 0; i < xwTitleLayout.getComponentCount(); i++) {
Component component = xwTitleLayout.getComponent(i);
if (component instanceof XElementCase) {
XElementCase xElementCase = (XElementCase) component;
xElementCase.toData().getElementCaseImage().updateImage(() -> {
xElementCase.setEditorIcon(xElementCase.toData().getECImage() == null ? DEFAULT_BACKGROUND : xElementCase.toData().getECImage());
if (xElementCase.designer != null) {
xElementCase.designer.repaint();
}
});
}
}
}
}
private void setEditorIcon(BufferedImage image) {
setLabelBackground(image, imageLable); setLabelBackground(image, imageLable);
} }
public Dimension getSize(){ public Dimension getSize() {
return new Dimension(this.getWidth(), this.getHeight()); return new Dimension(this.getWidth(), this.getHeight());
} }
@ -292,21 +311,21 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* @param editingMouseListener 事件处理器 * @param editingMouseListener 事件处理器
* @param e 点击事件 * @param e 点击事件
*/ */
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
super.respondClick(editingMouseListener, e); super.respondClick(editingMouseListener, e);
editingMouseListener.refreshTopXCreator(); editingMouseListener.refreshTopXCreator();
if (this.isShareConfigButtonFocus()) { if (this.isShareConfigButtonFocus()) {
CoverReportPane.showShareConfig(((XCreator)this.getParent()).toData()); CoverReportPane.showShareConfig(((XCreator) this.getParent()).toData());
} else { } else {
switchTab(e, editingMouseListener); switchTab(e, editingMouseListener);
} }
} }
private void switchTab(MouseEvent e,EditingMouseListener editingMouseListener){ private void switchTab(MouseEvent e, EditingMouseListener editingMouseListener) {
FormDesigner designer = editingMouseListener.getDesigner(); FormDesigner designer = editingMouseListener.getDesigner();
if (e.getButton() == MouseEvent.BUTTON1 && if (e.getButton() == MouseEvent.BUTTON1 &&
(e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR)){ (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR)) {
FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e); FormElementCaseContainerProvider component = (FormElementCaseContainerProvider) designer.getComponentAt(e);
//切换设计器 //切换设计器
designer.switchTab(component); designer.switchTab(component);
@ -315,14 +334,14 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
@Override @Override
public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() {
return new WidgetPropertyUIProvider[]{ new ElementCasePropertyUI(this)}; return new WidgetPropertyUIProvider[]{new ElementCasePropertyUI(this)};
} }
/** /**
* data属性改变触发其他操作 * data属性改变触发其他操作
* *
*/ */
public void firePropertyChange(){ public void firePropertyChange() {
initStyle(); initStyle();
} }
@ -330,7 +349,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
* 是否支持设置可用 * 是否支持设置可用
* return boolean * return boolean
*/ */
public boolean supportSetEnable(){ public boolean supportSetEnable() {
return false; return false;
} }

2
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -21,6 +21,7 @@ import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.form.ui.Connector; import com.fr.form.ui.Connector;
import com.fr.form.ui.ElementCaseImage;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
@ -335,6 +336,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
for (int i = 0, count = abs.getWidgetCount(); i < count; i++) { for (int i = 0, count = abs.getWidgetCount(); i < count; i++) {
BoundsWidget bw = (BoundsWidget) abs.getWidget(i); BoundsWidget bw = (BoundsWidget) abs.getWidget(i);
if (bw != null) { if (bw != null) {
ElementCaseImage.adjustImageSize(bw);
Rectangle bounds = bw.getBounds(); Rectangle bounds = bw.getBounds();
XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget()); XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget());
if (!comp.acceptType(XWParameterLayout.class)) { if (!comp.acceptType(XWParameterLayout.class)) {

3
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -12,6 +12,7 @@ import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.ElementCaseImage;
import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
@ -683,6 +684,7 @@ public class XWFitLayout extends XLayoutContainer {
for (int i=0, num=layout.getWidgetCount(); i<num ; i++) { for (int i=0, num=layout.getWidgetCount(); i<num ; i++) {
BoundsWidget bw = (BoundsWidget)layout.getWidget(i); BoundsWidget bw = (BoundsWidget)layout.getWidget(i);
if (bw != null) { if (bw != null) {
ElementCaseImage.adjustImageSize(bw);
Rectangle bounds = bw.getBounds(); Rectangle bounds = bw.getBounds();
bw.setBackupBounds(bounds); bw.setBackupBounds(bounds);
XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget()); XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget());
@ -766,6 +768,7 @@ public class XWFitLayout extends XLayoutContainer {
Rectangle rec = recalculateWidgetBounds(wgtBound, hors, veris); Rectangle rec = recalculateWidgetBounds(wgtBound, hors, veris);
wgt.setBounds(rec); wgt.setBounds(rec);
creator.toData().updateChildBounds(rec); creator.toData().updateChildBounds(rec);
XElementCase.updateECImage(creator);
if (rec.x == 0) { if (rec.x == 0) {
containerHeight += rec.height; containerHeight += rec.height;
} }

Loading…
Cancel
Save