Browse Source

Merge pull request #2655 in DESIGN/design from final/10.0 to release/10.0

* commit 'ffd5edf902666627112a9195d2020b6fd02aeca5':
  REPORT-41479 设计器参数界面宽度无法拖动
  REPORT-41492 jdk11设计器默认字体有不一致的情况
feature/big-screen
superman 4 years ago
parent
commit
fd80190c46
  1. 10
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  2. 67
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  3. 24
      designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java
  4. 11
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  5. 9
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  6. 15
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

10
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.constants.UIConstants;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel; 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.os.impl.SupportOSImpl;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont; 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.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
@ -57,7 +58,10 @@ public class ProgressDialog extends UIDialog {
progressBar.setMaximum(1000); progressBar.setMaximum(1000);
panel.add(progressBar, BorderLayout.CENTER); panel.add(progressBar, BorderLayout.CENTER);
text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.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); text.setFont(font);
panel.add(text, BorderLayout.SOUTH); panel.add(text, BorderLayout.SOUTH);
panel.setVisible(true); panel.setVisible(true);

67
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -8,6 +8,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.UILookAndFeel; import com.fr.design.gui.UILookAndFeel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.exit.DesignerExiter; import com.fr.exit.DesignerExiter;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
@ -21,7 +22,9 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.start.ServerStarter; import com.fr.start.ServerStarter;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
@ -248,6 +251,7 @@ public class DesignUtils {
// 刷新DesignerFrame里面的面板 // 刷新DesignerFrame里面的面板
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
if (DesignerContext.getDesignerFrame() == null) { if (DesignerContext.getDesignerFrame() == null) {
return; return;
@ -269,7 +273,7 @@ public class DesignUtils {
FineLoggerFactory.getLogger().error("Substance Raven Graphite failed to initialize"); FineLoggerFactory.getLogger().error("Substance Raven Graphite failed to initialize");
} }
//获取当前系统语言下设计器用的默认字体 //获取当前系统语言下设计器用的默认字体
FRFont guiFRFont = getCurrentLocaleFont(); FRFont guiFRFont = getDefaultGUIFont();
//指定UIManager中字体 //指定UIManager中字体
Enumeration keys = UIManager.getDefaults().keys(); Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) { while (keys.hasMoreElements()) {
@ -286,41 +290,50 @@ public class DesignUtils {
} }
/** /**
* 获取当前系统语言下设计器用的默认字体 * 获取当前系统语言下设计器界面使用的默认字体
* *
* @return 默认字体 * @return 默认字体
*/ */
private static FRFont getCurrentLocaleFont() { public static FRFont getDefaultGUIFont() {
FRFont guiFRFont; return CURRENT_LOCALE_FONT.getValue();
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");
}
//先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整. /**
Locale designerLocale = GeneralContext.getLocale(); * 获取当前系统语言下设计器用的默认字体
String file = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_File"); */
char displayChar = file.charAt(0); private static final NotNullLazyValue<FRFont> CURRENT_LOCALE_FONT = new NotNullLazyValue<FRFont>() {
if (!guiFRFont.canDisplay(displayChar)) { @NotNull
//如果不能用默认的语言显示字体, 比如想在英文系统里用中文设计器 @Override
//默认语言(中文:宋体, 英文:Tahoma, 其他:Dialog) protected FRFont compute() {
guiFRFont = getNamedFont("SimSun"); FRFont guiFRFont;
if (!guiFRFont.canDisplay(displayChar)) { 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"); 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)) { 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) { private static FRFont getNamedFont(String name) {
return FRFont.getInstance(name, Font.PLAIN, 12); return FRFont.getInstance(name, Font.PLAIN, 12);

24
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.FormArea;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormDesignerModeForSpecial; import com.fr.design.mainframe.FormDesignerModeForSpecial;
import com.fr.design.mainframe.FormDesignerUI;
import com.fr.design.mainframe.FormParaPane; import com.fr.design.mainframe.FormParaPane;
import com.fr.design.mainframe.FormWidgetDetailPane; import com.fr.design.mainframe.FormWidgetDetailPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
@ -58,6 +59,7 @@ import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -467,6 +469,21 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP
return ((FormParameterUI) getTarget()).getDesignSize(); 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(), return new JComponent[]{new CutAction(this).createToolBarComponent(), new CopyAction(this).createToolBarComponent(), new PasteAction(this).createToolBarComponent(),
new FormDeleteAction(this).createToolBarComponent()}; new FormDeleteAction(this).createToolBarComponent()};
} }
@Override
public boolean checkIfBeyondValidArea(MouseEvent e){
return false;
}
} }

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

@ -166,7 +166,7 @@ public class EditingMouseListener extends MouseInputAdapter {
// 获取焦点,以便获取热键 // 获取焦点,以便获取热键
designer.requestFocus(); designer.requestFocus();
} }
if (e.getButton() == MouseEvent.BUTTON1 && !beyondValidArea(e)) { if (e.getButton() == MouseEvent.BUTTON1 && !designer.checkIfBeyondValidArea(e)) {
Direction dir = selectionModel.getDirectionAt(e); Direction dir = selectionModel.getDirectionAt(e);
if (!DesignerMode.isAuthorityEditing()) { if (!DesignerMode.isAuthorityEditing()) {
@ -194,15 +194,6 @@ public class EditingMouseListener extends MouseInputAdapter {
e.translatePoint(oldX - e.getX(), oldY - e.getY()); 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){ private void offsetEventPoint(MouseEvent e){
int x = designer.getRelativeX(e.getX()); int x = designer.getRelativeX(e.getX());
int y = designer.getRelativeY(e.getY()); int y = designer.getRelativeY(e.getY());

9
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -1733,4 +1733,13 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return (int) (this.getArea().getVerticalValue() / this.scale); 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;
}
} }

15
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java

@ -424,12 +424,8 @@ public class FormDesignerUI extends ComponentUI {
// 禁止双缓冲 // 禁止双缓冲
ComponentUtils.disableBuffer(component, dbcomponents); ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg; Graphics clipg;
clipg = g.create( Rectangle clipgBounds = getFitPaintBounds(component, parent);
-designer.getHorizontalScaleValue(), clipg = g.create(clipgBounds.x, clipgBounds.y, clipgBounds.width, clipgBounds.height);
-designer.getVerticalScaleValue() + designer.getParaHeight(),
component.getSize().width + designer.getHorizontalScaleValue(),
component.getSize().height + designer.getVerticalScaleValue());
designer.paintContent(clipg); designer.paintContent(clipg);
paintWatermark((Graphics2D) clipg); paintWatermark((Graphics2D) clipg);
clipg.dispose(); clipg.dispose();
@ -439,6 +435,13 @@ public class FormDesignerUI extends ComponentUI {
designer.resetEditorComponentBounds(); 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());
}
/** /**
* 画参数面板 * 画参数面板
*/ */

Loading…
Cancel
Save