diff --git a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java index 29214984c3..d1847545ce 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java +++ b/designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java @@ -3,11 +3,12 @@ package com.fr.design.gui.iprogressbar; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.UIDialog; import com.fr.design.gui.ilable.UILabel; -import com.fr.stable.os.support.OSBasedAction; -import com.fr.stable.os.support.OSSupportCenter; import com.fr.design.os.impl.SupportOSImpl; +import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; import javax.swing.JDialog; import javax.swing.JLabel; @@ -57,7 +58,10 @@ public class ProgressDialog extends UIDialog { progressBar.setMaximum(1000); panel.add(progressBar, BorderLayout.CENTER); text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER); - FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334)); + FRFont font = DesignUtils + .getDefaultGUIFont() + .applySize(14) + .applyForeground(new ColorUIResource(333334)); text.setFont(font); panel.add(text, BorderLayout.SOUTH); panel.setVisible(true); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index b734110612..490b4e7e99 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -551,6 +551,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // 这个地方remove和add都是一个对象 完全没有必要remove再add 改变了窗口大小重新设置下 然后有repaint即可 basePane.setBounds(0, 0, contentWidth, contentHeight); layeredPane.repaint(); + layeredPane.revalidate(); } /** diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 2f0b73a60e..d3d2c59c6c 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -9,6 +9,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.UILookAndFeel; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.exit.DesignerExiter; import com.fr.file.FileFILE; @@ -23,7 +24,9 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.os.OperatingSystem; import com.fr.start.ServerStarter; +import com.fr.value.NotNullLazyValue; import com.fr.workspace.WorkContext; +import org.jetbrains.annotations.NotNull; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import javax.swing.SwingUtilities; @@ -251,6 +254,7 @@ public class DesignUtils { // 刷新DesignerFrame里面的面板 SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { if (DesignerContext.getDesignerFrame() == null) { return; @@ -272,7 +276,7 @@ public class DesignUtils { FineLoggerFactory.getLogger().error("Substance Raven Graphite failed to initialize"); } //获取当前系统语言下设计器用的默认字体 - FRFont guiFRFont = getCurrentLocaleFont(); + FRFont guiFRFont = getDefaultGUIFont(); //指定UIManager中字体 Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { @@ -289,41 +293,50 @@ public class DesignUtils { } /** - * 获取当前系统语言下设计器用的默认字体 + * 获取当前系统语言下设计器界面使用的默认字体 * * @return 默认字体 */ - private static FRFont getCurrentLocaleFont() { - FRFont guiFRFont; - Locale defaultLocale = Locale.getDefault(); - // JDK9 之后宋体在计算label中字母的空间上出现问题,暂时先用雅黑兼容,以后再统一字体 - if (StableUtils.getMajorJavaVersion() >= 9 && OperatingSystem.isWindows()) { - guiFRFont = getNamedFont("Microsoft YaHei"); - } else if (isDisplaySimSun(defaultLocale)) { - guiFRFont = getNamedFont("SimSun"); - } else { - guiFRFont = getNamedFont("Dialog"); - } + public static FRFont getDefaultGUIFont() { + return CURRENT_LOCALE_FONT.getValue(); + } - //先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整. - Locale designerLocale = GeneralContext.getLocale(); - String file = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_File"); - char displayChar = file.charAt(0); - if (!guiFRFont.canDisplay(displayChar)) { - //如果不能用默认的语言显示字体, 比如想在英文系统里用中文设计器 - //默认语言(中文:宋体, 英文:Tahoma, 其他:Dialog) - guiFRFont = getNamedFont("SimSun"); - if (!guiFRFont.canDisplay(displayChar)) { - //比如想在中文或英文系统里用韩文设计器 + /** + * 获取当前系统语言下设计器用的默认字体 + */ + private static final NotNullLazyValue CURRENT_LOCALE_FONT = new NotNullLazyValue() { + @NotNull + @Override + protected FRFont compute() { + FRFont guiFRFont; + Locale defaultLocale = Locale.getDefault(); + // JDK9 之后宋体在计算label中字母的空间上出现问题,暂时先用雅黑兼容,以后再统一字体 + if (StableUtils.getMajorJavaVersion() >= 9 && OperatingSystem.isWindows()) { + guiFRFont = getNamedFont("Microsoft YaHei"); + } else if (isDisplaySimSun(defaultLocale)) { + guiFRFont = getNamedFont("SimSun"); + } else { guiFRFont = getNamedFont("Dialog"); + } + + String file = Toolkit.i18nText("Fine-Design_Basic_File"); + char displayChar = file.charAt(0); + if (!guiFRFont.canDisplay(displayChar)) { + //如果不能用默认的语言显示字体, 比如想在英文系统里用中文设计器 + //默认语言(中文:宋体, 英文:Tahoma, 其他:Dialog) + guiFRFont = getNamedFont("SimSun"); if (!guiFRFont.canDisplay(displayChar)) { - FineLoggerFactory.getLogger().error(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_SimSun_Not_Found")); + //比如想在中文或英文系统里用韩文设计器 + guiFRFont = getNamedFont("Dialog"); + if (!guiFRFont.canDisplay(displayChar)) { + FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Base_SimSun_Not_Found")); + } } } - } - return guiFRFont; - } + return guiFRFont; + } + }; private static FRFont getNamedFont(String name) { return FRFont.getInstance(name, Font.PLAIN, 12); diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index 8956125eb3..8d13f3ab42 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -30,6 +30,7 @@ import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesignerModeForSpecial; +import com.fr.design.mainframe.FormDesignerUI; import com.fr.design.mainframe.FormParaPane; import com.fr.design.mainframe.FormWidgetDetailPane; import com.fr.design.mainframe.JTemplate; @@ -58,6 +59,7 @@ import java.awt.Graphics; import java.awt.Image; import java.awt.Insets; import java.awt.Rectangle; +import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -467,6 +469,21 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP return ((FormParameterUI) getTarget()).getDesignSize(); } + /** + * 设置其UI类为DesignerUI,负责渲染 + */ + @Override + public void updateUI() { + setUI(new FormDesignerUI(){ + @Override + protected Rectangle getFitPaintBounds(Component component, Component parent) { + return new Rectangle(0, 0, parent.getSize().width, parent.getSize().height); + } + + }); + } + + /** * 设置高度 * @@ -722,4 +739,11 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP return new JComponent[]{new CutAction(this).createToolBarComponent(), new CopyAction(this).createToolBarComponent(), new PasteAction(this).createToolBarComponent(), new FormDeleteAction(this).createToolBarComponent()}; } + + @Override + public boolean checkIfBeyondValidArea(MouseEvent e){ + return false; + } + + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 21b210a3bf..524dd8bf14 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -166,7 +166,7 @@ public class EditingMouseListener extends MouseInputAdapter { // 获取焦点,以便获取热键 designer.requestFocus(); } - if (e.getButton() == MouseEvent.BUTTON1 && !beyondValidArea(e)) { + if (e.getButton() == MouseEvent.BUTTON1 && !designer.checkIfBeyondValidArea(e)) { Direction dir = selectionModel.getDirectionAt(e); if (!DesignerMode.isAuthorityEditing()) { @@ -194,15 +194,6 @@ public class EditingMouseListener extends MouseInputAdapter { e.translatePoint(oldX - e.getX(), oldY - e.getY()); } - private boolean beyondValidArea(MouseEvent e) { - if (e.getX() < 0 || e.getY() < 0 || - e.getX() > designer.getRootComponent().getWidth() || - e.getY() > (designer.getRootComponent().getHeight() + designer.getParaHeight())) { - return true; - } - return false; - } - private void offsetEventPoint(MouseEvent e){ int x = designer.getRelativeX(e.getX()); int y = designer.getRelativeY(e.getY()); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 7be278d0f9..7923c3fa21 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -1735,4 +1735,13 @@ public class FormDesigner extends TargetComponent
implements TreeSelection return (int) (this.getArea().getVerticalValue() / this.scale); } + public boolean checkIfBeyondValidArea(MouseEvent e){ + if (e.getX() < 0 || e.getY() < 0 || + e.getX() > this.getRootComponent().getWidth() || + e.getY() > (this.getRootComponent().getHeight() + this.getParaHeight())) { + return true; + } + return false; + } + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 233ee2a96a..a21a2efad5 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -424,12 +424,8 @@ public class FormDesignerUI extends ComponentUI { // 禁止双缓冲 ComponentUtils.disableBuffer(component, dbcomponents); Graphics clipg; - clipg = g.create( - -designer.getHorizontalScaleValue(), - -designer.getVerticalScaleValue() + designer.getParaHeight(), - component.getSize().width + designer.getHorizontalScaleValue(), - component.getSize().height + designer.getVerticalScaleValue()); - + Rectangle clipgBounds = getFitPaintBounds(component, parent); + clipg = g.create(clipgBounds.x, clipgBounds.y, clipgBounds.width, clipgBounds.height); designer.paintContent(clipg); paintWatermark((Graphics2D) clipg); clipg.dispose(); @@ -439,6 +435,13 @@ public class FormDesignerUI extends ComponentUI { designer.resetEditorComponentBounds(); } + protected Rectangle getFitPaintBounds(Component component, Component parent) { + return new Rectangle(-designer.getHorizontalScaleValue(), + -designer.getVerticalScaleValue() + designer.getParaHeight(), + component.getSize().width + designer.getHorizontalScaleValue(), + component.getSize().height + designer.getVerticalScaleValue()); + } + /** * 画参数面板 */ diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java index 69e438401c..6d8d166794 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java @@ -118,8 +118,8 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { Component[][] components = new Component[][]{ new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Zoom_In_Logic"), SwingConstants.LEFT), new UILabel(ChartMobileFitAttrState.PROPORTION.description())}, new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Zoom_Out_Logic"), SwingConstants.LEFT), zoomOutComboBox}, - new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Collapse_Expand")), mobileCollapsedStyleEditor}, new Component[] {tipLabel, null}, + new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Collapse_Expand")), mobileCollapsedStyleEditor}, new Component[] {allowFullCheckBox, null}, new Component[] {functionalWhenUnactivatedCheckBox, null} };