Browse Source

Merge pull request #5082 in DESIGN/design from bugfix/10.0 to feature/10.0

* commit '69d4130f1b033e72d278aa4e7fd3d16b1658c083':
  REPORT-55228 工具栏问题  && REPORT-55228 设计器启动引导页面与切换账号页面 也要提示"更新相关组件"
  REPORT-55694 【组件背景分离】组件复用-组件/控件锁定时,通过右侧设置面板先增加宽度时,高度不变;但减小宽度时,高度会1单位1单位减小,最后组件变成一条横线
  REPORT-55709 frm中body背景设置了背景,不透明度设置0%没有透明效果
  REPORT-55553 【组件背景分离】组件复用-现在组件右侧设置面板的层次效果和视觉稿不一样,层次间隔不清晰
  REPORT-55492 【交互验收】【组件背景分离】macos中小工具栏的按钮区域浮到最上面来了(应该被dialog覆盖)
  REPORT-55228 【组件背景分离】组件复用-偶现,工具栏会留在设计页面上
  REPORT-55629 【组件背景分离】组件复用-控件/组件刚拖入设计画布时,工具栏没加载完全,只显示了一条线,移动鼠标的话才显示正常
  REPORT-55491 【交互验收】【组件背景分离】在组件属性下的「主体背景」设置,在配置界面不生效,看不到效果
  REPORT-55694 【组件背景分离】组件复用-组件/控件锁定时,通过右侧设置面板先增加宽度时,高度不变;但减小宽度时,高度会1单位1单位减小,最后组件变成一条横线
  REPORT-55672 悬浮元素-新建模板第一次添加的悬浮元素不能移动位置
  REPORT-55491 【交互验收】【组件背景分离】在组件属性下的「主体背景」设置,在配置界面不生效,看不到效果
  REPORT-55689 mac打开新插件管理也需要提示下更新新组件
feature/10.0
superman 3 years ago
parent
commit
21495ad514
  1. 3
      designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java
  2. 4
      designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java
  3. 2
      designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java
  4. 2
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java
  5. 6
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  6. 3
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  7. 12
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  8. 7
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  9. 2
      designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java
  10. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  11. 3
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  12. 23
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  13. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  14. 10
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  15. 18
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  16. 13
      designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java
  17. 5
      designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java
  18. 89
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  19. 2
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  20. 7
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  21. 70
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  22. 26
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java
  23. 11
      designer-realize/src/main/java/com/fr/grid/Grid.java
  24. 18
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java
  25. 6
      designer-realize/src/main/java/com/fr/grid/GridUI.java

3
designer-base/src/main/java/com/fr/design/PluginClassRefreshManager.java

@ -27,6 +27,8 @@ public class PluginClassRefreshManager {
private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() { private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() {
@Override @Override
public void on(PluginEvent event) { public void on(PluginEvent event) {
// 重载模版之前 触发下hide
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
// 兼容之前版本特性 // 兼容之前版本特性
for (String tag : context) { for (String tag : context) {
if (event.getContext().contain(tag)) { if (event.getContext().contain(tag)) {
@ -51,6 +53,7 @@ public class PluginClassRefreshManager {
public void on(PluginEvent event) { public void on(PluginEvent event) {
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener); PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, pluginAfterRunEventListener);
if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) {
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); HistoryTemplateListCache.getInstance().reloadAllEditingTemplate();
} }
} }

4
designer-base/src/main/java/com/fr/design/login/DesignerLoginHelper.java

@ -6,6 +6,7 @@ import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.update.ui.dialog.UpdateMainDialog; import com.fr.design.update.ui.dialog.UpdateMainDialog;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import java.awt.Dialog; import java.awt.Dialog;
@ -25,7 +26,7 @@ import javax.swing.WindowConstants;
public class DesignerLoginHelper { public class DesignerLoginHelper {
private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/login.html"; private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/login.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser"; private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
private static UIDialog dialog = null; private static UIDialog dialog = null;
@ -91,6 +92,7 @@ public class DesignerLoginHelper {
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.setVisible(false); dialog.setVisible(false);
dialog = null; dialog = null;
DesignerPluginContext.setPluginDialog(null);
} }
} }

2
designer-base/src/main/java/com/fr/design/login/DesignerLoginShowDialog.java

@ -1,6 +1,7 @@
package com.fr.design.login; package com.fr.design.login;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
@ -36,6 +37,7 @@ public class DesignerLoginShowDialog extends UIDialog {
setSize(DEFAULT); setSize(DEFAULT);
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
setResizable(false); setResizable(false);
DesignerPluginContext.setPluginDialog(this);
} }
@Override @Override

2
designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java

@ -22,7 +22,7 @@ import javax.swing.WindowConstants;
public class DesignerGuideHelper { public class DesignerGuideHelper {
private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/guide.html"; private static final String MAIN_RESOURCE_PATH = "/com/fr/design/login/guide.html";
private static final String JXBROWSER = "com.teamdev.jxbrowser.chromium.Browser"; private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
private static final long ONE_WEEK = 7 * 24 * 3600 * 1000L; private static final long ONE_WEEK = 7 * 24 * 3600 * 1000L;
private static final long ONE_MONTH = 30 * 24 * 3600 * 1000L; private static final long ONE_MONTH = 30 * 24 * 3600 * 1000L;
private static final long SIX_MONTH = 6 * ONE_MONTH; private static final long SIX_MONTH = 6 * ONE_MONTH;

6
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -212,6 +212,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
@Override
public void windowIconified(WindowEvent e) {
// 最小化时 hide工具栏
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
}
}; };
private JComponent closeButton = new JComponent() { private JComponent closeButton = new JComponent() {

3
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -15,7 +15,6 @@ import com.fr.event.Listener;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.WorkspaceEvent;
@ -32,7 +31,7 @@ public class UpmFinder {
private static final String UPM_DIR = "/upm"; private static final String UPM_DIR = "/upm";
private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html"; private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html";
private static final String JXBROWSER = OperatingSystem.isWindows() ? "com.teamdev.jxbrowser.browser.Browser" : "com.teamdev.jxbrowser.chromium.Browser"; private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser";
public static String installHome = FRContext.getCommonOperator().getWebRootPath(); public static String installHome = FRContext.getCommonOperator().getWebRootPath();

12
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -43,6 +43,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public ChartComponent() { public ChartComponent() {
super(); super();
setOpaque(true);
addMouseListener(this); addMouseListener(this);
addMouseMotionListener(this); addMouseMotionListener(this);
} }
@ -148,11 +149,12 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false); chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint(); if (this.isOpaque()) {
Paint oldPaint = g2d.getPaint();
g2d.setPaint(Color.WHITE); g2d.setPaint(Color.WHITE);
g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height); g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height);
g2d.setPaint(oldPaint); g2d.setPaint(oldPaint);
}
g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2); g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2);

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

@ -9,6 +9,7 @@ import com.fr.design.designer.properties.BoundsGroupModel;
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel;
import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
@ -295,6 +296,12 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
*/ */
@Override @Override
public void fix(XCreator creator) { public void fix(XCreator creator) {
Widget widget = creator.toData();
Rectangle bounds = creator.getBounds();
if (widget != null && widget.isAspectRatioLocked() && (bounds.width == 0 || bounds.height == 0)) {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
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());

2
designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java

@ -93,7 +93,7 @@ public class DesignerEditor<T extends JComponent> implements PropertyChangeListe
comp.setSize(new Dimension(width, height)); comp.setSize(new Dimension(width, height));
LayoutUtils.layoutContainer(comp); LayoutUtils.layoutContainer(comp);
comp.setBounds(comp.getX() + x, comp.getY() + y, width, height); comp.setBounds(comp.getX() + x - 1, comp.getY() + y - 1, width, height);
Graphics clipg = g.create(x, y, width, height); Graphics clipg = g.create(x, y, width, height);
this.comp.paint(clipg); this.comp.paint(clipg);
} }

4
designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

@ -226,7 +226,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paintBackground(Graphics2D g2d) { public void paintBackground(Graphics2D g2d) {
Background background4Painting = getBackground4Painting(); Background background4Painting = getBackground4Painting();
if (background4Painting != null) { if (background4Painting != null) {
BorderPacker style = toData().getBorderStyle();
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, style.getAlpha()));
background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight())); background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
g2d.setComposite(oldComposite);
} }
} }

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

@ -231,7 +231,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
public void paintForeground(Graphics2D g) { public void paintForeground(Graphics2D g) {
Dimension size = getSize(); Dimension size = getSize();
PaddingMargin margin = toData().getMargin(); PaddingMargin margin = toData().getMargin();
designerEditor.paintEditor(g, size, margin); designerEditor.paintEditor(g, size, margin);
if (coverPanel != null) { if (coverPanel != null) {
int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0; int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0;
int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0; int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0;
@ -289,6 +291,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection()); final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection());
if (chartComponent != null) { if (chartComponent != null) {
JComponent jChart = chartComponent; JComponent jChart = chartComponent;
chartComponent.setOpaque(false);
jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray)); jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray));
designerEditor = new DesignerEditor<JComponent>(jChart); designerEditor = new DesignerEditor<JComponent>(jChart);
chartComponent.addStopEditingListener(designerEditor); chartComponent.addStopEditingListener(designerEditor);

23
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -23,6 +23,7 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.plugin.DesignerPluginContext;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
@ -33,6 +34,7 @@ import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.Border; import javax.swing.border.Border;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
@ -776,10 +778,23 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
} }
int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale()); int extraX = (int) ((bounds.x + bounds.width + SelectedPopupDialog.OFFSET_X) * designer.getScale());
int extraY = (int) (bounds.y * designer.getScale()); int extraY = (int) (bounds.y * designer.getScale());
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY); // 放到事件尾部执行
popup.updatePane(designer); SwingUtilities.invokeLater(new Runnable() {
popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible()); @Override
popup.setRelativeBounds(bounds); public void run() {
popup.setLocation(designer.getLocationOnScreen().x + designer.getPaintX() + extraX, designer.getLocationOnScreen().y + designer.getPaintY() + extraY);
popup.updatePane(designer);
popup.setVisible(selected && accept && popup.hasVisibleButtons() && popup.isCanVisible() && !isShowPluginDialog());
popup.setRelativeBounds(bounds);
}
});
}
private boolean isShowPluginDialog() {
if (DesignerPluginContext.getPluginDialog() == null) {
return false;
}
return DesignerPluginContext.getPluginDialog().isVisible();
} }
/** /**

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

@ -41,7 +41,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
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_translucent.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);
@ -183,7 +183,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
if (editor == null) { if (editor == null) {
setBorder(DEFALUTBORDER); setBorder(DEFALUTBORDER);
editor = new JPanel(); editor = new JPanel();
editor.setBackground(null); editor.setOpaque(false);
editor.setBackground(new Color(0, 0, 0, 0));
editor.setLayout(null); editor.setLayout(null);
imageLable = initImageBackground(); imageLable = initImageBackground();
@ -218,7 +219,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
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(false);
imageLable.setBackground(new Color(0, 0, 0, 0));
imageLable.setLayout(null); imageLable.setLayout(null);
imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
} }

10
designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java

@ -19,6 +19,7 @@ import com.fr.form.ui.Label;
import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.act.BorderPacker;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -91,8 +92,13 @@ public class XLabel extends XWidgetCreator {
Label label = (Label) data; Label label = (Label) data;
Dimension size = this.getSize(); Dimension size = this.getSize();
//先画背景,再画标题 //先画背景,再画标题
if (toData().getBackground() != null) { Background background = label.getBackground();
toData().getBackground().paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight())); if (background != null) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, label.getBackgroundOpacity()));
background.paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()));
g2d.setComposite(oldComposite);
} }
if (label.getWidgetValue() != null) { if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();

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

@ -386,7 +386,18 @@ public class XWAbsoluteLayout extends XLayoutContainer {
if (!creator.acceptType(XWFitLayout.class)) { if (!creator.acceptType(XWFitLayout.class)) {
creator.setDirections(Direction.ALL); creator.setDirections(Direction.ALL);
} }
wabs.addWidget(new BoundsWidget(creator.toData(), creator.getBounds())); Widget wgt = creator.toData();
if (wgt != null && wgt.isAspectRatioLocked() && wgt.getAspectRatioBackup() <= 0) {
// 将比例锁定的组件重新移会绝对布局内时(如body修改绝对布局),尺寸比例可能失效,需要重新计算
Rectangle bounds = creator.getBounds();
if (bounds.width > 0 && bounds.height > 0) {
wgt.setAspectRatioBackup(1.0 * bounds.width / bounds.height);
} else {
wgt.setAspectRatioLocked(false);
wgt.setAspectRatioBackup(-1);
}
}
wabs.addWidget(new BoundsWidget(wgt, creator.getBounds()));
} }
/** /**
@ -402,6 +413,11 @@ public class XWAbsoluteLayout extends XLayoutContainer {
WAbsoluteLayout wlayout = this.toData(); WAbsoluteLayout wlayout = this.toData();
XWidgetCreator xwc = ((XWidgetCreator) e.getChild()); XWidgetCreator xwc = ((XWidgetCreator) e.getChild());
Widget wgt = xwc.toData(); Widget wgt = xwc.toData();
// 将比例锁定的组件重新移出绝对布局时(如body修改为自适应布局),锁定的尺寸比例失效
if (wgt != null) {
wgt.setAspectRatioBackup(-1.0);
}
BoundsWidget bw = new BoundsWidget(wgt, xwc.getBounds()); BoundsWidget bw = new BoundsWidget(wgt, xwc.getBounds());
wlayout.removeWidget(bw); wlayout.removeWidget(bw);
} }

13
designer-form/src/main/java/com/fr/design/designer/ui/PopupControlPanel.java

@ -13,6 +13,7 @@ import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -94,7 +95,17 @@ public class PopupControlPanel extends JPanel {
JToggleButton toggleBtn = (JToggleButton) e.getSource(); JToggleButton toggleBtn = (JToggleButton) e.getSource();
String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio"); String toolTipText = toggleBtn.isSelected() ? Toolkit.i18nText("Fine-Design_Form_Lock_Widget_Ratio") : Toolkit.i18nText("Fine-Design_Form_UnLock_Widget_Ratio");
toggleBtn.setToolTipText(toolTipText); toggleBtn.setToolTipText(toolTipText);
creator.toData().setAspectRatioLocked(toggleBtn.isSelected()); Widget widget = creator.toData();
if (widget != null) {
Rectangle bounds = new Rectangle(creator.getBounds());
if (toggleBtn.isSelected() && bounds.width > 0 && bounds.height > 0) {
widget.setAspectRatioLocked(true);
widget.setAspectRatioBackup(1.0 * bounds.width / bounds.height);
} else {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
}
designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RESIZED); designer.getEditListenerTable().fireCreatorModified(creator, DesignerEvent.CREATOR_RESIZED);
} }
}); });

5
designer-form/src/main/java/com/fr/design/designer/ui/SelectedPopupDialog.java

@ -3,8 +3,11 @@ package com.fr.design.designer.ui;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.stable.os.OperatingSystem;
import java.awt.Rectangle; import java.awt.Rectangle;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JFrame;
/** /**
* @author hades * @author hades
@ -23,7 +26,7 @@ public class SelectedPopupDialog extends JDialog {
private boolean canVisible = true; private boolean canVisible = true;
public SelectedPopupDialog(XCreator creator, FormDesigner designer) { public SelectedPopupDialog(XCreator creator, FormDesigner designer) {
super(DesignerContext.getDesignerFrame()); super(OperatingSystem.isMacos() ? new JFrame() : DesignerContext.getDesignerFrame());
this.setUndecorated(true); this.setUndecorated(true);
this.setModal(false); this.setModal(false);
this.setFocusableWindowState(false); this.setFocusableWindowState(false);

89
designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java

@ -1,10 +1,8 @@
package com.fr.design.gui.xpane; package com.fr.design.gui.xpane;
import com.fr.base.GraphHelper;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
@ -13,7 +11,6 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
@ -105,42 +102,46 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane(); boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane();
JPanel titlePane = createTitleStylePane(); JPanel titlePane = createTitleStylePane();
JPanel bodyContentPane = currentIsRootLayout ? createBodyContentPane4RootLayout() : createBodyContentPane();
JPanel backgroundPane = createBackgroundStylePane();
if (titlePane != null) { if (titlePane != null) {
container.add(titlePane, BorderLayout.NORTH); container.add(titlePane, BorderLayout.NORTH);
if (currentIsRootLayout) { if (currentIsRootLayout) {
titlePane.setVisible(false); titlePane.setVisible(false);
} }
} }
JPanel nextContainerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.add(nextContainerPane, BorderLayout.CENTER);
//界面上表单主体只有背景和透明度可以设置 if (bodyContentPane != null) {
JPanel mainStylePane = currentIsRootLayout ? createMainStylePane4RootLayout() : createMainStylePane4WidgetLayout(); //界面上表单主体只有背景和透明度可以设置
if (mainStylePane != null) { nextContainerPane.add(bodyContentPane, BorderLayout.NORTH);
container.add(mainStylePane, BorderLayout.CENTER); }
if (backgroundPane != null) {
nextContainerPane.add(backgroundPane, BorderLayout.CENTER);
if (currentIsRootLayout) {
backgroundPane.setVisible(false);
}
} }
this.add(container, BorderLayout.CENTER); this.add(container, BorderLayout.CENTER);
} }
protected void initMainComponents() { protected JPanel createBackgroundStylePane() {
borderStyleCombo = new UIComboBox(BORDER_STYLE); borderStyleCombo = new UIComboBox(BORDER_STYLE);
borderLineAndImagePane = new BorderLineAndImagePane(); borderLineAndImagePane = new BorderLineAndImagePane();
cornerSpinner = new UISpinner(0,1000,1,0); cornerSpinner = new UISpinner(0,1000,1,0);
backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
}
protected JPanel createMainStylePane4WidgetLayout() {
initMainComponents();
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p, p}; double[] rowSize = {p, p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f}; double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Background_Style")), null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Render_Style")), borderStyleCombo},
{this.borderLineAndImagePane, null}, {this.borderLineAndImagePane, null},
{this.createMainBackgroundAndOpacityPane(), null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner},
}, },
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
@ -153,16 +154,23 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return container; return container;
} }
protected JPanel createMainStylePane4RootLayout() { protected JPanel createBodyContentPane() {
initMainComponents(); backgroundPane = new LayoutBackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] rowSize = {p, p}; double[] rowSize = {p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f}; double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel bodyBackground = createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"),
this.backgroundPane,
this.backgroundOpacityPane);
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Content")), null},
{this.createMainBackgroundAndOpacityPane(), null}, {bodyBackground, null},
}, },
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
@ -174,11 +182,31 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
return container; return container;
} }
protected JPanel createMainBackgroundAndOpacityPane() { protected JPanel createBodyContentPane4RootLayout() {
return createBackgroundAndOpacityPane( backgroundPane = new LayoutBackgroundSpecialPane();
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background"), backgroundOpacityPane = new UIPercentDragPane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel bodyBackground = createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Fill"),
this.backgroundPane, this.backgroundPane,
this.backgroundOpacityPane); this.backgroundOpacityPane);
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{bodyBackground, null},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(new BottomLineBorder());
container.add(contentPane, BorderLayout.NORTH);
return container;
} }
protected void initTitleComponents() { protected void initTitleComponents() {
@ -489,16 +517,25 @@ public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
protected static class BottomLineBorder extends LineBorder { protected static class BottomLineBorder extends LineBorder {
public BottomLineBorder() { public BottomLineBorder() {
super(Color.lightGray, 1); super(new Color(217, 218, 221), 1);
} }
@Override @Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor(); Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor); Stroke oldStroke = g2d.getStroke();
GraphHelper.drawLine(g, 0, height, width, height, 1);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor());
g2d.setStroke(new BasicStroke(getThickness() * 2));
g2d.drawLine(0, height, width, height);
g2d.setStroke(oldStroke);
g2d.setColor(oldColor); g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
} }
} }

2
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -647,7 +647,7 @@ public class EditingMouseListener extends MouseInputAdapter {
@Override @Override
public void run() { public void run() {
for (XCreator xCreator : xCreators) { for (XCreator xCreator : xCreators) {
xCreator.setSelected(true); xCreator.setSelected(!e.isShiftDown());
} }
} }
}); });

7
designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java

@ -112,7 +112,12 @@ public class FormCreatorDropTarget extends DropTarget {
if (addingXCreator.isShared()) { if (addingXCreator.isShared()) {
if (container.acceptType(XWAbsoluteLayout.class)) { if (container.acceptType(XWAbsoluteLayout.class)) {
// 绝对布局中新添加的共享组件默认锁定尺寸比例 // 绝对布局中新添加的共享组件默认锁定尺寸比例
addingXCreator.toData().setAspectRatioLocked(true); Rectangle bounds = new Rectangle(addingXCreator.getBounds());
Widget addingWidget = addingXCreator.toData();
if (addingWidget != null && bounds.width > 0 && bounds.height > 0) {
addingXCreator.toData().setAspectRatioLocked(true);
addingXCreator.toData().setAspectRatioBackup(1.0 * bounds.width / bounds.height);
}
} }
String shareId = addingXCreator.getShareId(); String shareId = addingXCreator.getShareId();

70
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java

@ -103,14 +103,11 @@ public class WidgetBoundPane extends BasicPane {
} }
public void populate() { public void populate() {
Rectangle bounds = new Rectangle(creator.getBounds()); if (ratioLockedButton == null) {
if (ratioLockedButton != null) { Rectangle bounds = new Rectangle(creator.getBounds());
// 临时禁止尺寸比例锁定,关掉widthSpinner/heightSpinner之间的数值关联,以更新其高度和宽度值 width.setValue(bounds.width);
ratioLockedButton.setLocked(false); height.setValue(bounds.height);
} } else {
width.setValue(bounds.width);
height.setValue(bounds.height);
if (ratioLockedButton != null) {
ratioLockedButton.populate(creator); ratioLockedButton.populate(creator);
} }
} }
@ -213,8 +210,7 @@ public class WidgetBoundPane extends BasicPane {
private final UISpinner mWidthSpinner; private final UISpinner mWidthSpinner;
private final UISpinner mHeightSpinner; private final UISpinner mHeightSpinner;
protected double width4Backup = 0; protected double aspectRatioBackup = 0;
protected double height4Backup = 0;
public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner) { public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner) {
setUI(new BasicButtonUI()); setUI(new BasicButtonUI());
@ -229,12 +225,16 @@ public class WidgetBoundPane extends BasicPane {
addActionListener(new ActionListener() { addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// 改变图标icon double width = mWidthSpinner.getValue();
setLocked(!isLocked()); double height = mHeightSpinner.getValue();
boolean nextLocked = !isLocked();
if (isLocked() && isLockEnabled()) {
width4Backup = mWidthSpinner.getValue(); if (nextLocked && width > 0 && height > 0) {
height4Backup = mHeightSpinner.getValue(); setLocked(true);
aspectRatioBackup = width / height;
} else {
setLocked(false);
aspectRatioBackup = -1;
} }
if (globalNameListener != null) { if (globalNameListener != null) {
@ -250,16 +250,28 @@ public class WidgetBoundPane extends BasicPane {
mWidthSpinner.addChangeListener(new ChangeListener() { mWidthSpinner.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) { if (isLockEnabled() && isLocked()) {
mHeightSpinner.setValue(mWidthSpinner.getValue() * height4Backup / width4Backup, false); if (mWidthSpinner.getValue() == 0) {
setLocked(false);
aspectRatioBackup = -1;
} else if (aspectRatioBackup > 0) {
double value = mWidthSpinner.getValue() / aspectRatioBackup;
mHeightSpinner.setValue(Math.round(value), false);
}
} }
} }
}); });
mHeightSpinner.addChangeListener(new ChangeListener() { mHeightSpinner.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) { if (isLockEnabled() && isLocked()) {
mWidthSpinner.setValue(mHeightSpinner.getValue() * width4Backup / height4Backup, false); if (mHeightSpinner.getValue() == 0) {
setLocked(false);
aspectRatioBackup = -1;
}else if (aspectRatioBackup > 0) {
double value = mHeightSpinner.getValue() * aspectRatioBackup;
mWidthSpinner.setValue(Math.round(value), false);
}
} }
} }
}); });
@ -301,14 +313,26 @@ public class WidgetBoundPane extends BasicPane {
public void populate(XCreator creator) { public void populate(XCreator creator) {
Rectangle bounds = new Rectangle(creator.getBounds()); Rectangle bounds = new Rectangle(creator.getBounds());
width4Backup = bounds.width;
height4Backup = bounds.height;
Widget widget = creator.toData(); Widget widget = creator.toData();
aspectRatioBackup = widget.getAspectRatioBackup();
setLocked(widget.isAspectRatioLocked()); setLocked(widget.isAspectRatioLocked());
mWidthSpinner.setValue(bounds.width, false);
mHeightSpinner.setValue(bounds.height, false);
} }
public void update(XCreator creator) { public void update(XCreator creator) {
creator.toData().setAspectRatioLocked(this.isLocked()); Widget widget = creator.toData();
if (widget != null) {
if (this.isLocked()) {
widget.setAspectRatioLocked(true);
widget.setAspectRatioBackup(this.aspectRatioBackup);
} else {
widget.setAspectRatioLocked(false);
widget.setAspectRatioBackup(-1.0);
}
}
} }
@Override @Override

26
designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java

@ -43,9 +43,9 @@ import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics; import java.awt.Graphics2D;
import java.awt.Transparency;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
/** /**
@ -129,19 +129,23 @@ public class FormElementCaseDesigner
public BufferedImage getElementCaseImage(Dimension size) { public BufferedImage getElementCaseImage(Dimension size) {
BufferedImage image = null; BufferedImage image = null;
try { try {
image = new java.awt.image.BufferedImage(size.width, size.height, int width = size.width;
java.awt.image.BufferedImage.TYPE_INT_RGB); int height = size.height;
Graphics g = image.getGraphics();
//填充白色背景, 不然有黑框 image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Color oldColor = g.getColor(); Graphics2D g2d = image.createGraphics();
g.setColor(Color.WHITE); // 创建一个支持透明背景的buffer image
g.fillRect(0, 0, size.width, size.height); image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT);
g.setColor(oldColor); g2d.dispose();
g2d = image.createGraphics();
Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null;
if (grid != null) { if (grid != null) {
grid.paintAll(g); boolean oldTranslucent = grid.isTranslucent();
// 截缩图图时grid需支持半透明,不能用默认白色填充画布,否则会遮挡组件样式背景
grid.setTranslucent(true);
grid.paint(g2d);
grid.setTranslucent(oldTranslucent);
} }
} catch (Exception e) { } catch (Exception e) {

11
designer-realize/src/main/java/com/fr/grid/Grid.java

@ -134,6 +134,9 @@ public class Grid extends BaseGridComponent {
private boolean needRequestFocus = true; private boolean needRequestFocus = true;
// 截取缩略图时需透明(不能用默认白色填充),否则会遮挡组件样式的背景,其余情况的绘制可以用白色等默认颜色填充
private boolean isTranslucent = false;
public Grid(int resolution) { public Grid(int resolution) {
this.resolution = resolution; this.resolution = resolution;
// 能触发processEvent,不管是否给component增加listener // 能触发processEvent,不管是否给component增加listener
@ -1458,4 +1461,12 @@ public class Grid extends BaseGridComponent {
this.paginateLineShowType = paginateLineShowType; this.paginateLineShowType = paginateLineShowType;
this.getElementCasePane().repaint(); this.getElementCasePane().repaint();
} }
public boolean isTranslucent() {
return isTranslucent;
}
public void setTranslucent(boolean translucent) {
isTranslucent = translucent;
}
} }

18
designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

@ -408,11 +408,11 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
int currentWidth = currentRight - currentLeft; int currentWidth = currentRight - currentLeft;
int currentHeight = currentBottom - currentTop; int currentHeight = currentBottom - currentTop;
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) { if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) {
if (aspectRatio) { if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2); double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2);
double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2); double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2);
@ -452,7 +452,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setTopDistance(topDistance); floatElement.setTopDistance(topDistance);
floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu)); floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu));
if (aspectRatio) { if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
currentWidth = backupWidth * currentHeight / backupHeight; currentWidth = backupWidth * currentHeight / backupHeight;
currentRight = currentLeft + currentWidth; currentRight = currentLeft + currentWidth;
FU floatX1_fu = FU.valueOfPix(currentLeft, resolution); FU floatX1_fu = FU.valueOfPix(currentLeft, resolution);
@ -465,7 +468,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setLeftDistance(leftDistance); floatElement.setLeftDistance(leftDistance);
floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu)); floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu));
if (aspectRatio) { if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
currentHeight = backupHeight * currentWidth / backupWidth; currentHeight = backupHeight * currentWidth / backupWidth;
currentBottom = currentTop + currentHeight; currentBottom = currentTop + currentHeight;
FU floatY1_fu = FU.valueOfPix(currentTop, resolution); FU floatY1_fu = FU.valueOfPix(currentTop, resolution);

6
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -1128,8 +1128,10 @@ public class GridUI extends ComponentUI {
double realWidth = gridSize.getWidth();// 宽度 double realWidth = gridSize.getWidth();// 宽度
double realHeight = gridSize.getHeight();// 高度 double realHeight = gridSize.getHeight();// 高度
// 画背景 if (!grid.isTranslucent()) {
this.paintBackground(g2d, grid, elementCase, resolution); // 画背景
this.paintBackground(g2d, grid, elementCase, resolution);
}
// 画Grid Line // 画Grid Line
this.paintGridLine(g2d, grid, elementCase, realWidth, realHeight, resolution); this.paintGridLine(g2d, grid, elementCase, realWidth, realHeight, resolution);

Loading…
Cancel
Save