Browse Source

Merge pull request #4870 in DESIGN/design from release/11.0 to feature/x

* commit 'a2a265898160c3795d1e012135dc50df6e9163d7':
  REPORT-54844 jar包相同情况下,同步插件时同步按钮一直没灰化
  REPORT-54817 内网环境下该迭代功能应当不生效
  CHART-19720  控件顺序反了
  REPORT-53699 更改监听BeforeAllStop事件
  REPORT-52847 【10.0.18】部分数据连接支持fetchsize
  REPORT-54438 单元格属性设置面板 在切换参数面板编辑后 面板未刷新
  REPORT-53175【10.0.18】组件背景分离为标题/背景/边框
  REPORT-54716 决策报表中修改组件名为大写,提示重名
  REPORT-54716 决策报表中修改组件名为大写,提示重名
  REPORT-54116 设计器绝对布局内可锁定组件宽高比例
  REPORT-52847 【10.0.18】部分数据连接支持fetchsize
  REPORT-53175 【10.0.18】组件背景分离为标题/背景/边框
  REPORT-53175【10.0.18】组件背景分离为标题/背景/边框
  REPORT-54116 设计器绝对布局内可锁定组件宽高比例
research/11.0
superman 3 years ago
parent
commit
b4ebd477f4
  1. 138
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java
  2. 5
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  3. 47
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCConnectionDef.java
  4. 2
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  5. 30
      designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java
  6. 55
      designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java
  7. 10
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java
  8. 4
      designer-base/src/main/java/com/fr/design/login/AbstractDesignerSSO.java
  9. 6
      designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java
  10. 3
      designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java
  11. 19
      designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java
  12. 23
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java
  13. 48
      designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java
  14. 2
      designer-base/src/main/java/com/fr/env/CheckServiceDialog.java
  15. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png
  16. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_choose_inset.png
  17. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_delete_inset.png
  18. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png
  19. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png
  20. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png
  21. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png
  22. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_selected.png
  23. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_unselected.png
  24. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png
  25. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_enabled.png
  26. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png
  27. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_enabled.png
  28. BIN
      designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg
  29. 12
      designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java
  30. 11
      designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java
  31. 11
      designer-form/src/main/java/com/fr/design/designer/beans/location/Bottom.java
  32. 11
      designer-form/src/main/java/com/fr/design/designer/beans/location/Left.java
  33. 20
      designer-form/src/main/java/com/fr/design/designer/beans/location/LeftBottom.java
  34. 23
      designer-form/src/main/java/com/fr/design/designer/beans/location/LeftTop.java
  35. 13
      designer-form/src/main/java/com/fr/design/designer/beans/location/Right.java
  36. 18
      designer-form/src/main/java/com/fr/design/designer/beans/location/RightBottom.java
  37. 20
      designer-form/src/main/java/com/fr/design/designer/beans/location/RightTop.java
  38. 11
      designer-form/src/main/java/com/fr/design/designer/beans/location/Top.java
  39. 11
      designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java
  40. 16
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  41. 14
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  42. 598
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  43. 27
      designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java
  44. 502
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  45. 258
      designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java
  46. 7
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  47. 12
      designer-form/src/main/java/com/fr/design/mainframe/FormEditorKeyListener.java
  48. 13
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java
  49. 16
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java
  50. 6
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java
  51. 149
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  52. 14
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java
  53. 91
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  54. 93
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  55. 13
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java
  56. 36
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java
  57. 4
      designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java
  58. 81
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

138
designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java

@ -1,8 +1,9 @@
package com.fr.design.data.datapane.connect;
import com.fr.base.GraphHelper;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.pool.DBCPConnectionPoolAttr;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.gui.icombobox.UIComboBox;
@ -12,14 +13,35 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.BorderFactory;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DBCPAttrPane extends BasicPane {
public static final int TIME_MULTIPLE = 1000;
private static final Pattern FETCHSIZE_PATTERN = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$");;
private static final Pattern CHAR_NEED_ESCAPE = Pattern.compile("[?|$^*\\\\\\[\\](){}.+]");
private static final int MAX_FETCHSIZE = 1000000;
private static final Map<String, Integer> DEFAULT_FETCHSIZE_MAP = new HashMap<>();
private static final int ORACLE_DEFAULT_FETCHSIZE = 128;
private static final int DB2_DEFAULT_FETCHSIZE = 50;
private static final int POSTGRE_DEFAULT_FETCHSIZE = 10000;
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
@ -36,11 +58,24 @@ public class DBCPAttrPane extends BasicPane {
private IntegerEditor DBCP_NUMTESTSPEREVICTIONRUN = new IntegerEditor();
private IntegerEditor DBCP_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor();
private UITextField FETCHSIZE = new UITextField();
private JPanel defaultPane;
private JPanel northFlowPane;
private JPanel southFlowPane;
static {
DEFAULT_FETCHSIZE_MAP.put("Oracle", ORACLE_DEFAULT_FETCHSIZE);
DEFAULT_FETCHSIZE_MAP.put("DB2", DB2_DEFAULT_FETCHSIZE);
DEFAULT_FETCHSIZE_MAP.put("Postgre", POSTGRE_DEFAULT_FETCHSIZE);
}
public DBCPAttrPane() {
JPanel defaultPane = this;
defaultPane = this;
// JPanel northFlowPane
JPanel northFlowPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
northFlowPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
northFlowPane.setPreferredSize(new Dimension(630, 320));
defaultPane.add(northFlowPane, BorderLayout.NORTH);
DBCP_VALIDATION_QUERY.setColumns(15);
@ -67,7 +102,6 @@ public class DBCPAttrPane extends BasicPane {
DBCP_MINEVICTABLEIDLETIMEMILLIS}};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
contextPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, UIConstants.LINE_COLOR));
northFlowPane.add(contextPane);
}
@ -89,6 +123,10 @@ public class DBCPAttrPane extends BasicPane {
this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE);
this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun());
this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis());
Integer fetchSize = DEFAULT_FETCHSIZE_MAP.get(JDBCConnectionDef.getInstance().getDatabaseName());
if (fetchSize != null) {
this.FETCHSIZE.setText(jdbcDatabase.getFetchSize() == -1 ? String.valueOf(fetchSize) : String.valueOf(jdbcDatabase.getFetchSize()));
}
}
public void update(JDBCDatabaseConnection jdbcDatabase) {
@ -109,10 +147,94 @@ public class DBCPAttrPane extends BasicPane {
dbcpAttr.setMinEvictableIdleTimeMillis(((Number) this.DBCP_MINEVICTABLEIDLETIMEMILLIS.getValue()).intValue() * TIME_MULTIPLE);
dbcpAttr.setNumTestsPerEvictionRun(((Number) this.DBCP_NUMTESTSPEREVICTIONRUN.getValue()).intValue());
dbcpAttr.setTimeBetweenEvictionRunsMillis(((Number) this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.getValue()).intValue());
Integer fetchSize = DEFAULT_FETCHSIZE_MAP.get(JDBCConnectionDef.getInstance().getDatabaseName());
if (fetchSize != null) {
jdbcDatabase.setFetchSize(Integer.parseInt(this.FETCHSIZE.getText()));
}
}
@Override
public BasicDialog showWindow(Window window) {
String databaseName = JDBCConnectionDef.getInstance().getDatabaseName();
if (showOtherConfig(databaseName)) {
southFlowPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Other"));
southFlowPane.setPreferredSize(new Dimension(630, 200));
double f = TableLayout.FILL;
double[] rowSize = {f};
double otherColumnSize = GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis")) + 6;
double[] columnSize = {otherColumnSize, otherColumnSize};
FETCHSIZE.addKeyListener(fetchSizeKeyListener);
FETCHSIZE.addInputMethodListener(fetchSizeInputMethodListener);
FETCHSIZE.setHorizontalAlignment(JTextField.RIGHT);
Component[][] comps = {
{new UILabel("Fetchsize:", SwingConstants.RIGHT), FETCHSIZE}
};
JPanel otherConfigPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
southFlowPane.add(otherConfigPane);
defaultPane.removeAll();
defaultPane.add(northFlowPane, BorderLayout.NORTH);
defaultPane.add(southFlowPane, BorderLayout.SOUTH);
} else {
if (southFlowPane != null) {
defaultPane.remove(southFlowPane);
}
}
return this.showWindow(window, null);
}
private boolean showOtherConfig(Object dbType) {
return ComparatorUtils.equals(dbType, "Oracle") || ComparatorUtils.equals(dbType, "DB2") || ComparatorUtils.equals(dbType, "Postgre");
}
KeyListener fetchSizeKeyListener = new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
String fetchSize = FETCHSIZE.getText();
if (!isFetchSizeValid(fetchSize)) {
FETCHSIZE.setText(fetchSize.replaceAll(getCharNeedReplace(e.getKeyChar()), ""));
if (!isFetchSizeValid(FETCHSIZE.getText())) {
FETCHSIZE.setText(StringUtils.EMPTY);
}
} else if (FETCHSIZE.getText().length() > String.valueOf(MAX_FETCHSIZE).length() || Long.parseLong(FETCHSIZE.getText()) > MAX_FETCHSIZE) {
FETCHSIZE.setText(String.valueOf(MAX_FETCHSIZE));
}
}
};
InputMethodListener fetchSizeInputMethodListener = new InputMethodListener() {
@Override
public void inputMethodTextChanged(InputMethodEvent event) {
if (null == event.getText()) {
return;
}
char ch = event.getText().current();
if (!(ch >= '0' && ch <= '9')) {
event.consume();
}
}
@Override
public void caretPositionChanged(InputMethodEvent event) {
}
};
private boolean isFetchSizeValid(String fetchSize) {
return FETCHSIZE_PATTERN.matcher(fetchSize).find();
}
private String getCharNeedReplace(char c) {
String charNeedReplace = c + "";
Matcher matcher = CHAR_NEED_ESCAPE.matcher(charNeedReplace);
if (matcher.find()) {
charNeedReplace = "\\" + charNeedReplace;
}
return charNeedReplace;
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr");
return Toolkit.i18nText("Fine-Design_Basic_Advanced_Setup");
}
}

5
designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -12,7 +12,6 @@ import com.fr.data.solution.entity.DriverPage;
import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor;
import com.fr.data.solution.processor.SolutionProcessor;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.ActionLabel;
@ -338,7 +337,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
Toolkit.i18nText("Fine-Design_Basic_Advanced")
));
if (mainPanel instanceof JDBCDefPane) {
ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_Advanced_Setup"));
actionLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JDialog wDialog = createJDialog();
@ -418,7 +417,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
return false;
}
protected static BasicPane getAdvancedAttrPane() {
protected static DBCPAttrPane getAdvancedAttrPane() {
return dbcpAttrPane;
}

47
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCConnectionDef.java

@ -0,0 +1,47 @@
package com.fr.design.data.datapane.connect;
import com.fr.data.impl.JDBCDatabaseConnection;
/**
* JDBCDefPane和DBCPAttrPane沟通的桥梁
*
*/
public class JDBCConnectionDef {
private static volatile JDBCConnectionDef instance;
private String databaseName;
private JDBCDatabaseConnection connection;
public static JDBCConnectionDef getInstance() {
if (instance == null) {
synchronized (JDBCConnectionDef.class) {
if (instance == null) {
instance = new JDBCConnectionDef();
}
}
}
return instance;
}
private JDBCConnectionDef() {
}
public String getDatabaseName() {
return databaseName;
}
public void setDatabaseName(String databaseName) {
this.databaseName = databaseName;
}
public JDBCDatabaseConnection getConnection() {
return connection;
}
public void setConnection(String databaseName, JDBCDatabaseConnection connection) {
this.databaseName = databaseName;
this.connection = connection;
}
}

2
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -330,6 +330,8 @@ public class JDBCDefPane extends JPanel {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
changePane(dbtypeComboBox.getSelectedItem());
JDBCConnectionDef.getInstance().setConnection((String) dbtypeComboBox.getSelectedItem(), jdbcDatabase);
DatabaseConnectionPane.JDBC.getAdvancedAttrPane().populate(jdbcDatabase);
}
};

30
designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java

@ -0,0 +1,30 @@
package com.fr.design.gui.frpane;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.*;
import java.awt.*;
/**
* @author Starryi
* @version 10.0.18
* Created by Starryi on 2021/7/3
*/
public class UIPercentDragPane extends JPanel {
private final UINumberDragPane dragPane = new UINumberDragPane(0, 100, 1);
public UIPercentDragPane() {
setLayout(new BorderLayout());
add(dragPane, BorderLayout.CENTER);
add(new UILabel(" %"), BorderLayout.EAST);
}
public void populateBean(double value) {
dragPane.populateBean(value * 100);
}
public double updateBean() {
return dragPane.updateBean() * 100;
}
}

55
designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java

@ -3,22 +3,14 @@
*/
package com.fr.design.gui.icombobox;
import com.fr.base.FRContext;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.general.FRFont;
import com.fr.stable.Constants;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JList;
/**
@ -59,6 +51,13 @@ public class LineComboBox extends UIComboBox {
this.setSelectedItem(new Integer(style));
}
protected String toStringFromStyle(int style) {
if (style == Constants.LINE_NONE) {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None");
}
return null;
}
/**
* CellRenderer.
*/
@ -67,31 +66,27 @@ public class LineComboBox extends UIComboBox {
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel comp= (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.style = ((Integer) value).intValue();
comp.setText(null);
String displayString = toStringFromStyle(style);
if (StringUtils.isNotEmpty(displayString)) {
comp.setText(" " + displayString);
} else {
comp.setText(null);
}
return comp;
}
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
Dimension d = getSize();
g2d.setColor(getForeground());
FRFont font = FRContext.getDefaultValues().getFRFont();
int resolution = ScreenResolution.getScreenResolution();
Font rfont = font.applyResolutionNP(resolution);
g2d.setFont(rfont);
FontMetrics fm = GraphHelper.getFontMetrics(rfont);
if (style == Constants.LINE_NONE) {
//draw "none" string
GraphHelper.drawString(g2d, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2D + fm.getAscent());
} else {
if (StringUtils.isEmpty(toStringFromStyle(style))) {
Graphics2D g2d = (Graphics2D) g;
Dimension d = getSize();
g2d.setColor(getForeground());
GraphHelper.drawLine(g2d, 4, d.height / 2D, d.width - 8D, d.height / 2D, style);
}
if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式.
drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D));
if(isShowAxisWithLineStyle()) { // 带有坐标轴箭头的样式.
drawArrow(g2d, new Point2D.Double(4, d.height / 2D), new Point2D.Double(d.width - 8D, d.height / 2D));
}
}
}

10
designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java

@ -70,13 +70,13 @@ public class BackgroundPane extends AbstractBasicStylePane {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{null, null},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill") + " ", SwingConstants.LEFT),typeComboBox},
new Component[]{null, centerPane}
new Component[]{null},
new Component[]{typeComboBox},
new Component[]{centerPane}
};
double[] rowSize = {p, p, p};
double[] columnSize = {p,f};
int[][] rowCount = {{1, 1},{1, 1},{1, 1}};
double[] columnSize = {f};
int[][] rowCount = {{1},{1},{1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM);
this.add(panel, BorderLayout.CENTER);

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

@ -20,6 +20,10 @@ public abstract class AbstractDesignerSSO extends UpdateAction {
@Override
public void actionPerformed(ActionEvent event) {
String url = getJumpUrl();
if (!DesignerLoginUtils.isOnline()) {
BrowseUtils.browser(url);
return;
}
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
int uid = manager.getDesignerLoginUid();
if (uid > 0) {

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

@ -4,9 +4,13 @@ import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.UIDialog;
import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.login.utils.DesignerLoginUtils;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.update.push.DesignerPushUpdateManager;
import com.fr.general.CloudCenter;
import com.fr.general.CloudCenterConfig;
import com.fr.general.http.HttpToolbox;
import com.fr.stable.StringUtils;
import javax.swing.WindowConstants;
@ -35,7 +39,7 @@ public class DesignerGuideHelper {
public static void prepareShowGuideDialog() {
// 如果存在更新升级的弹窗,则不显示引导页面
if (!SupportOSImpl.DESIGNER_LOGIN.support() || !FRContext.isChineseEnv() || DesignerPushUpdateManager.getInstance().isShouldPopUp()) {
if (!DesignerLoginUtils.isOnline() || !SupportOSImpl.DESIGNER_LOGIN.support() || !FRContext.isChineseEnv() || DesignerPushUpdateManager.getInstance().isShouldPopUp()) {
return;
}
if (isActivatedForOneWeek()) {

3
designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java

@ -51,6 +51,9 @@ public class DesignerMessageHelper {
}
public void prepareShowMessage() {
if (!DesignerLoginUtils.isOnline()) {
return;
}
DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() {
@Override
public void designerOpened() {

19
designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java

@ -3,10 +3,13 @@ package com.fr.design.login.utils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.general.CloudCenter;
import com.fr.general.CloudCenterConfig;
import com.fr.general.GeneralContext;
import com.fr.general.http.HttpToolbox;
import com.fr.general.log.MessageFormatter;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.third.org.bouncycastle.util.encoders.Hex;
import java.awt.Window;
import java.security.SecureRandom;
@ -49,6 +52,9 @@ public class DesignerLoginUtils {
}
public static String generateDesignerSSOUrl(String referrer) {
if (!DesignerLoginUtils.isOnline()) {
return referrer;
}
String ssoTemplate = CloudCenter.getInstance().acquireUrlByKind("designer.sso.api", "https://id.fanruan.com/api/app/?code={}&referrer={}");
try {
String code = generateLoginCode();
@ -60,6 +66,19 @@ public class DesignerLoginUtils {
return referrer;
}
public static boolean isOnline() {
if (CloudCenterConfig.getInstance().isOnline()) {
String ping = CloudCenter.getInstance().acquireConf("ping", StringUtils.EMPTY);
if (StringUtils.isNotEmpty(ping)) {
try {
return StringUtils.isEmpty(HttpToolbox.get(ping));
} catch (Exception ignore) {
}
}
}
return false;
}
private static String generateLoginCode() throws Exception {
DesignerEnvManager manager = DesignerEnvManager.getEnvManager();
JSONObject jo = JSONObject.create();

23
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java

@ -52,8 +52,15 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre
private boolean isLoading = false;
public ImagePreviewPane() {
sizeLabel = new UILabel();
this.add(sizeLabel);
this(true);
}
public ImagePreviewPane(boolean showSizeLabel) {
if (showSizeLabel) {
sizeLabel = new UILabel();
this.add(sizeLabel);
}
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 20, 10));
this.setLayout(new BorderLayout());
this.add(new JPanel() {
@ -117,7 +124,9 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre
((JViewport) this.getParent()).setMinimumSize(newDimension);
((JViewport) this.getParent()).setMaximumSize(newDimension);
}
sizeLabel.setText(null);
if (sizeLabel != null) {
sizeLabel.setText(null);
}
} else {
isLoading = false;
// wait for the size of image.
@ -128,10 +137,14 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre
int totalwidth = ImagePreviewPane.this.getWidth();
int totalheight = ImagePreviewPane.this.getHeight();
String text = imageWidth + "x" + imageHeight;
sizeLabel.setText(text);
if (sizeLabel != null) {
sizeLabel.setText(text);
}
FontMetrics cellFM = this.getFontMetrics(getFont());
int width = cellFM.stringWidth(text);
sizeLabel.setBounds(totalwidth - width - LABEL_DELTA_X, totalheight - LABEL_DELTA_Y, width, LABEL_HEIGHT);
if (sizeLabel != null) {
sizeLabel.setBounds(totalwidth - width - LABEL_DELTA_X, totalheight - LABEL_DELTA_Y, width, LABEL_HEIGHT);
}
}
fireChangeListener();
this.revalidate();

48
designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java

@ -10,6 +10,7 @@ import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
@ -45,23 +46,28 @@ public class WidgetBoundsPaneFactory {
private static final int RIGHT_PANE_WIDTH = 145;
public static UIExpandablePane createBoundsPane(UISpinner width, UISpinner height) {
public static UIExpandablePane createBoundsPane(UISpinner width, UISpinner height, JComponent ratioLocked) {
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)},
new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Component_Size")),
ratioLocked != null ? createRightPane(width, ratioLocked, height) : createRightPane(width, height)},
new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))},
};
double[] rowSize = {p, p};
double[] columnSize = {f, RIGHT_PANE_WIDTH};
int[][] rowCount = {{1, 1}, {1, 1}};
int[][] rowCount = ratioLocked != null ? new int[][]{{1, 1}, {1, 1, 1}} : new int[][]{{1, 1}, {1, 1}};
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W5, IntervalConstants.INTERVAL_L6);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
boundsPane.add(panel);
return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 280, 24, boundsPane);
}
public static UIExpandablePane createBoundsPane(UISpinner width, UISpinner height) {
return createBoundsPane(width, height, null);
}
public static JPanel createRightPane(Component com1, Component com2) {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
@ -74,21 +80,41 @@ public class WidgetBoundsPaneFactory {
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L1);
}
public static UIExpandablePane createAbsoluteBoundsPane(UISpinner x, UISpinner y, UISpinner width, UISpinner height, NameAttribute nameAttribute) {
public static JPanel createRightPane(Component com1, Component com2, Component com3) {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p};
double[] columnSize = {f, 24, f};
int[][] rowCount = {{1, 1, 1}};
Component[][] components = new Component[][]{
new Component[]{com1, com2, com3}
};
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 0, IntervalConstants.INTERVAL_L1);
}
public static UIExpandablePane createAbsoluteBoundsPane(UISpinner x, UISpinner y, UISpinner width, UISpinner height, JComponent ratioLocked, NameAttribute nameAttribute) {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
UILabel positionLabel = FRWidgetFactory.createLineWrapLabel(nameAttribute.getPositionName());
UILabel xLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER);
UILabel yLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER);
UILabel sizeLabel = FRWidgetFactory.createLineWrapLabel(nameAttribute.getSizeName());
UILabel widthLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER);
UILabel heightLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER);
Component[][] northComponents = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(nameAttribute.getPositionName()), createRightPane(x, y)},
new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER))},
new Component[]{positionLabel, ratioLocked != null ? createRightPane(x, null, y) : createRightPane(x, y)},
new Component[]{null, ratioLocked != null ? createRightPane(xLabel, null, yLabel) : createRightPane(xLabel, yLabel)},
};
Component[][] centerComponents = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(nameAttribute.getSizeName()), createRightPane(width, height)},
new Component[]{null, createRightPane(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))},
new Component[]{sizeLabel, ratioLocked != null ? createRightPane(width, ratioLocked, height) : createRightPane(width, height)},
new Component[]{null, ratioLocked != null ? createRightPane(widthLabel, null, heightLabel) : createRightPane(widthLabel, heightLabel)},
};
double[] rowSize = {p, p};
double[] columnSize = {f, RIGHT_PANE_WIDTH};
int[][] rowCount = {{1, 1}, {1, 1}};
int[][] rowCount = ratioLocked != null ? new int[][]{{1, 1, 1}, {1, 1, 1}} : new int[][]{{1, 1}, {1, 1}};
final JPanel northPanel = TableLayoutHelper.createGapTableLayoutPane(northComponents, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W5, IntervalConstants.INTERVAL_L6);
final JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(centerComponents, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W5, IntervalConstants.INTERVAL_L6);
JPanel boundsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -99,6 +125,10 @@ public class WidgetBoundsPaneFactory {
return new UIExpandablePane(Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"), 230, 24, boundsPane);
}
public static UIExpandablePane createAbsoluteBoundsPane(UISpinner x, UISpinner y, UISpinner width, UISpinner height, NameAttribute nameAttribute) {
return createAbsoluteBoundsPane(x, y, width, height, null, nameAttribute);
}
public static UIExpandablePane createAbsoluteBoundsPane(UISpinner x, UISpinner y, UISpinner width, UISpinner height) {
return createAbsoluteBoundsPane(x, y, width, height, NameAttribute.DEFAULT);
}

2
designer-base/src/main/java/com/fr/env/CheckServiceDialog.java vendored

@ -309,6 +309,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
@Override
public void mouseClicked(MouseEvent e) {
ignoreButton.setEnabled(false);
syncButton.setEnabled(false);
String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")};
if (!jarConsistency) {
int a = FineJOptionPane.showOptionDialog(getParent(), Toolkit.i18nText("Fine-Design_Basic_Sync_Info_Information"),
@ -350,6 +351,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
@Override
protected JSONArray doInBackground() {
progressBar.setVisible(true);
progressBar.setString(Toolkit.i18nText("Fine-Design_Basic_Sync_Plugins"));
progressBar.setValue(0);
return VersionCheckUtils.syncPlugins(differentPlugins);

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_choose_inset.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_delete_inset.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_selected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_unselected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_enabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_enabled.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

BIN
designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

12
designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java

@ -209,9 +209,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
}
private void createChangeEnablePane(VanChartRectanglePlot plot) {
String scroll = Toolkit.i18nText("Fine-Design_Chart_Scroll");
String scaleAxis = Toolkit.i18nText("Fine-Design_Chart_Scale_Axis");
controlType = new UIButtonGroup<>(new String[]{scroll, scaleAxis}, ControlType.values());
String scroll = Toolkit.i18nText("Fine-Design_Chart_Scroll");
controlType = new UIButtonGroup<>(new String[]{scaleAxis, scroll}, ControlType.values());
JPanel scaleAxisPane = createScaleAxisPane();
JPanel scrollPane = createScrollPane(plot);
@ -225,8 +225,8 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
}
}
};
centerPane.add(scaleAxisPane, scroll);
centerPane.add(scrollPane, scaleAxis);
centerPane.add(scaleAxisPane, scaleAxis);
centerPane.add(scrollPane, scroll);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
@ -291,9 +291,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane<Chart> {
if (centerPane != null && controlType != null) {
CardLayout cardLayout = (CardLayout) centerPane.getLayout();
if (controlType.getSelectedItem() == ControlType.ZOOM) {
cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Scroll"));
} else {
cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Scale_Axis"));
} else {
cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Scroll"));
}
}
}

11
designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java

@ -3,6 +3,8 @@
*/
package com.fr.design.designer.beans.location;
import com.fr.config.ServerPreferenceConfig;
import com.fr.config.utils.ConfigReadUtils;
import com.fr.design.beans.location.Absorptionline;
import com.fr.design.beans.location.MoveUtils;
import com.fr.design.designer.creator.*;
@ -193,9 +195,18 @@ public abstract class AccessDirection implements Direction {
if (type != formEditor.getCursor().getType()) {
// 设置当前形状
formEditor.setCursor(Cursor.getPredefinedCursor(type));
ServerPreferenceConfig config = ServerPreferenceConfig.getInstance();
if (!config.isHasShownLockedAspectRatioResizingToolTip()) {
formEditor.setToolTipText(getTooltip());
config.setHasShownLockedAspectRatioResizingToolTip(true);
}
}
}
public String getTooltip() {
return null;
}
/**
* 生成组件备用的bound
* @param formEditor 设计界面组件

11
designer-form/src/main/java/com/fr/design/designer/beans/location/Bottom.java

@ -15,6 +15,12 @@ public class Bottom extends AccessDirection {
Rectangle oldbounds) {
current_bounds.height = sorption(0, oldbounds.height + dy + oldbounds.y, current_bounds, designer)[1]
- oldbounds.y;
if (designer.getStateModel().isAspectRatioLocked()) {
Rectangle backupBounds = designer.getSelectionModel().getSelection().getBackupBounds();
current_bounds.width = (int) (backupBounds.width * current_bounds.height / backupBounds.height * 1.0);
}
return current_bounds;
}
@ -23,6 +29,11 @@ public class Bottom extends AccessDirection {
return Cursor.S_RESIZE_CURSOR;
}
@Override
public String getTooltip() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Mouse_ToolTip");
}
@Override
public int getActual() {
return Direction.BOTTOM;

11
designer-form/src/main/java/com/fr/design/designer/beans/location/Left.java

@ -15,6 +15,12 @@ public class Left extends AccessDirection {
Rectangle oldbounds) {
current_bounds.x = sorption(oldbounds.x + dx, 0, current_bounds, designer)[0];
current_bounds.width = oldbounds.width - current_bounds.x + oldbounds.x;
if (designer.getStateModel().isAspectRatioLocked()) {
Rectangle backupBounds = designer.getSelectionModel().getSelection().getBackupBounds();
current_bounds.height = (int) (backupBounds.height * current_bounds.width / backupBounds.width * 1.0);
}
return current_bounds;
}
@ -23,6 +29,11 @@ public class Left extends AccessDirection {
return Cursor.W_RESIZE_CURSOR;
}
@Override
public String getTooltip() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Mouse_ToolTip");
}
@Override
public int getActual() {
return Direction.LEFT;

20
designer-form/src/main/java/com/fr/design/designer/beans/location/LeftBottom.java

@ -17,6 +17,21 @@ public class LeftBottom extends AccessDirection {
current_bounds.x = xy[0];
current_bounds.width = oldbounds.width - current_bounds.x + oldbounds.x;
current_bounds.height = xy[1] - oldbounds.y;
if (designer.getStateModel().isAspectRatioLocked()) {
Rectangle backupBounds = designer.getSelectionModel().getSelection().getBackupBounds();
double current_diagonal = Math.pow(current_bounds.width, 2) + Math.pow(current_bounds.height, 2);
double backup_diagonal = Math.pow(backupBounds.width, 2) + Math.pow(backupBounds.height, 2);
int width = (int) (Math.sqrt((current_diagonal / backup_diagonal) * (Math.pow(backupBounds.width, 2))));
int height = (int) (Math.sqrt((current_diagonal / backup_diagonal) * (Math.pow(backupBounds.height, 2))));
int currentRight = current_bounds.x + current_bounds.width;
current_bounds.width = width;
current_bounds.height = height;
current_bounds.x = currentRight - width;
}
return current_bounds;
}
@ -25,6 +40,11 @@ public class LeftBottom extends AccessDirection {
return Cursor.SW_RESIZE_CURSOR;
}
@Override
public String getTooltip() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Mouse_ToolTip");
}
@Override
public int getActual() {
return Direction.LEFT_BOTTOM;

23
designer-form/src/main/java/com/fr/design/designer/beans/location/LeftTop.java

@ -6,6 +6,7 @@ import java.awt.Rectangle;
import com.fr.design.mainframe.FormDesigner;
public class LeftTop extends AccessDirection {
public LeftTop() {
}
@ -17,6 +18,23 @@ public class LeftTop extends AccessDirection {
current_bounds.y = xy[1];
current_bounds.width = oldbounds.width - current_bounds.x + oldbounds.x;
current_bounds.height = oldbounds.height - current_bounds.y + oldbounds.y;
if (designer.getStateModel().isAspectRatioLocked()) {
Rectangle backupBounds = designer.getSelectionModel().getSelection().getBackupBounds();
double current_diagonal = Math.pow(current_bounds.width, 2) + Math.pow(current_bounds.height, 2);
double backup_diagonal = Math.pow(backupBounds.width, 2) + Math.pow(backupBounds.height, 2);
int width = (int) (Math.sqrt((current_diagonal / backup_diagonal) * (Math.pow(backupBounds.width, 2))));
int height = (int) (Math.sqrt((current_diagonal / backup_diagonal) * (Math.pow(backupBounds.height, 2))));
int currentRight = current_bounds.x + current_bounds.width;
int currentBottom = current_bounds.y + current_bounds.height;
current_bounds.width = width;
current_bounds.height = height;
current_bounds.x = currentRight - width;
current_bounds.y = currentBottom - height;
}
return current_bounds;
}
@ -25,6 +43,11 @@ public class LeftTop extends AccessDirection {
return Cursor.NW_RESIZE_CURSOR;
}
@Override
public String getTooltip() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Mouse_ToolTip");
}
@Override
public int getActual() {
return Direction.LEFT_TOP;

13
designer-form/src/main/java/com/fr/design/designer/beans/location/Right.java

@ -3,7 +3,9 @@ package com.fr.design.designer.beans.location;
import java.awt.Cursor;
import java.awt.Rectangle;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
public class Right extends AccessDirection {
@ -15,6 +17,12 @@ public class Right extends AccessDirection {
Rectangle oldbounds) {
current_bounds.width = sorption(oldbounds.x + dx + oldbounds.width, 0, current_bounds, designer)[0]
- oldbounds.x;
if (designer.getStateModel().isAspectRatioLocked()) {
Rectangle backupBounds = designer.getSelectionModel().getSelection().getBackupBounds();
current_bounds.height = (int) (backupBounds.height * current_bounds.width / backupBounds.width * 1.0);
}
return current_bounds;
}
@ -23,6 +31,11 @@ public class Right extends AccessDirection {
return Cursor.E_RESIZE_CURSOR;
}
@Override
public String getTooltip() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Mouse_ToolTip");
}
@Override
public int getActual() {
return Direction.RIGHT;

18
designer-form/src/main/java/com/fr/design/designer/beans/location/RightBottom.java

@ -16,6 +16,19 @@ public class RightBottom extends AccessDirection {
int[] xy = sorption(oldbounds.x + dx + oldbounds.width, oldbounds.height + dy + oldbounds.y, current_bounds, designer);
current_bounds.width = xy[0] - oldbounds.x;
current_bounds.height = xy[1] - oldbounds.y;
if (designer.getStateModel().isAspectRatioLocked()) {
Rectangle backupBounds = designer.getSelectionModel().getSelection().getBackupBounds();
double current_diagonal = Math.pow(current_bounds.width, 2) + Math.pow(current_bounds.height, 2);
double backup_diagonal = Math.pow(backupBounds.width, 2) + Math.pow(backupBounds.height, 2);
int width = (int) (Math.sqrt((current_diagonal / backup_diagonal) * (Math.pow(backupBounds.width, 2))));
int height = (int) (Math.sqrt((current_diagonal / backup_diagonal) * (Math.pow(backupBounds.height, 2))));
current_bounds.width = width;
current_bounds.height = height;
}
return current_bounds;
}
@ -24,6 +37,11 @@ public class RightBottom extends AccessDirection {
return Cursor.SE_RESIZE_CURSOR;
}
@Override
public String getTooltip() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Mouse_ToolTip");
}
@Override
public int getActual() {
return Direction.RIGHT_BOTTOM;

20
designer-form/src/main/java/com/fr/design/designer/beans/location/RightTop.java

@ -16,6 +16,21 @@ public class RightTop extends AccessDirection {
current_bounds.y = xy[1];
current_bounds.height = oldbounds.height - current_bounds.y + oldbounds.y;
current_bounds.width = xy[0] - oldbounds.x;
if (designer.getStateModel().isAspectRatioLocked()) {
Rectangle backupBounds = designer.getSelectionModel().getSelection().getBackupBounds();
double current_diagonal = Math.pow(current_bounds.width, 2) + Math.pow(current_bounds.height, 2);
double backup_diagonal = Math.pow(backupBounds.width, 2) + Math.pow(backupBounds.height, 2);
int width = (int) (Math.sqrt((current_diagonal / backup_diagonal) * (Math.pow(backupBounds.width, 2))));
int height = (int) (Math.sqrt((current_diagonal / backup_diagonal) * (Math.pow(backupBounds.height, 2))));
int currentBottom = current_bounds.y + current_bounds.height;
current_bounds.width = width;
current_bounds.height = height;
current_bounds.y = currentBottom - height;
}
return current_bounds;
}
@ -24,6 +39,11 @@ public class RightTop extends AccessDirection {
return Cursor.NE_RESIZE_CURSOR;
}
@Override
public String getTooltip() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Mouse_ToolTip");
}
@Override
public int getActual() {
return Direction.RIGHT_TOP;

11
designer-form/src/main/java/com/fr/design/designer/beans/location/Top.java

@ -15,6 +15,12 @@ public class Top extends AccessDirection {
Rectangle oldbounds) {
current_bounds.y = sorption(0, dy + oldbounds.y, current_bounds, designer)[1];
current_bounds.height = oldbounds.height - current_bounds.y + oldbounds.y;
if (designer.getStateModel().isAspectRatioLocked()) {
Rectangle backupBounds = designer.getSelectionModel().getSelection().getBackupBounds();
current_bounds.width = (int) (backupBounds.width * current_bounds.height / backupBounds.height * 1.0);
}
return current_bounds;
}
@ -23,6 +29,11 @@ public class Top extends AccessDirection {
return Cursor.N_RESIZE_CURSOR;
}
@Override
public String getTooltip() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Mouse_ToolTip");
}
@Override
public int getActual() {
return Direction.TOP;

11
designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java

@ -55,6 +55,8 @@ public class StateModel {
// 当前是否处于拖拽选择状态
private boolean selecting;
private boolean dragging;
// 拖拽时需要保持组件尺寸比例
private boolean aspectRatioLocked;
private boolean addable;
@ -83,6 +85,10 @@ public class StateModel {
return selecting;
}
public boolean isAspectRatioLocked() {
return this.aspectRatioLocked;
}
/**
* 是否能拖拽
*
@ -393,6 +399,7 @@ public class StateModel {
* 重置model
*/
public void resetModel() {
aspectRatioLocked = false;
dragging = false;
selecting = false;
}
@ -402,6 +409,7 @@ public class StateModel {
*/
public void reset() {
driection = Location.outer;
aspectRatioLocked = false;
dragging = false;
selecting = false;
}
@ -478,10 +486,12 @@ public class StateModel {
public void dragging(MouseEvent e) {
//进入dragging状态时备份组件大小和位置
if (!dragging) {
this.aspectRatioLocked = this.selectionModel.getSelection().isCreatorAspectRatioLockedInAbsLayout(designer);
selectedPositionBackup = selectionModel.getSelection().getRelativeBounds();
}
checkAddable(e);
setDependLinePainter(e);
this.aspectRatioLocked = this.aspectRatioLocked || e.isShiftDown();
driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer);
this.dragging = true;
}
@ -508,6 +518,7 @@ public class StateModel {
* @param e 鼠标事件
*/
public void releaseDragging(MouseEvent e) {
this.aspectRatioLocked = false;
this.dragging = false;
if (addable) {
adding(e.getX(), e.getY());

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

@ -48,7 +48,15 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
return (AbstractBorderStyleWidget) data;
}
protected void initStyle() {
@Override
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight) {
super.addToWrapper(parentPanel, width, minHeight);
// REPORT-53175: 新创建的图表组件默认显示标题 since 10.0.18
// 将当前对象添加到父容器后,初始化默认样式的效果
initStyle();
}
protected void initStyle() {
BorderPacker style = toData().getBorderStyle();
initBorderStyle();
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
@ -121,6 +129,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
title.setFont(wTitle.getFrFont());
title.setTextalign(wTitle.getPosition());
title.setBackground(wTitle.getBackground());
title.setBackgroundOpacity(wTitle.getBackgroundOpacity());
title.setInsetImage(wTitle.getInsetImage());
title.setInsetImagePadding(wTitle.getInsetImagePadding());
title.setInsetRelativeTextLeft(wTitle.isInsetRelativeTextLeft());
title.setInsetRelativeTextRight(wTitle.isInsetRelativeTextRight());
}
private WidgetValue getTitleValue(TitlePacker wTitle){

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

@ -5,6 +5,7 @@ package com.fr.design.designer.creator;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.base.background.ImageBackground;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.form.util.FontTransformUtil;
import com.fr.design.form.util.XCreatorConstants;
@ -17,6 +18,7 @@ import com.fr.design.mainframe.widget.renderer.LabelHorizontalAlignmentRenderer;
import com.fr.form.ui.Label;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter;
@ -94,10 +96,18 @@ public class XLabel extends XWidgetCreator {
}
if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create();
BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), label.getWidgetValue()
.toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign())
Background inset = label.getInsetImage();
Image insetImage = inset instanceof ImageBackground ? ((ImageBackground) inset).getImage() : null;
BaseUtils.drawStringStyleInRotation(g2d,
this.getWidth(), this.getHeight(),
label.getWidgetValue().toString(),
Style.getInstance(label.getFont())
.deriveHorizontalAlignment(label.getTextalign())
.deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP)
.deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE),
insetImage, label.getInsetImagePadding(), label.isInsetRelativeTextLeft(), label.isInsetRelativeTextRight(),
FontTransformUtil.getDesignerFontResolution());
}

598
designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java

@ -0,0 +1,598 @@
package com.fr.design.gui.xpane;
import com.fr.base.GraphHelper;
import com.fr.base.Style;
import com.fr.base.Utils;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.ImgChooseWrapper;
import com.fr.design.gui.frpane.UIPercentDragPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itooltip.UIToolTip;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.backgroundpane.ImagePreviewPane;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.Background;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
/**
* @author Starryi
* @version 10.0.18
* Created by Starryi on 2021/7/2
*
* 可配置图片类型边框的样式设置面板
*/
public class BorderLineAndImagePane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = 60;
private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT);
private final String TWEAK_NINE_POINT_HELP_URL = "";
private UIObserverListener uiObserverListener;
private BorderLineAndImageComboBox borderLineCombo;
private UIColorButton borderColorPane;
private ImagePreviewPane imagePreviewPane;
private UIButton chooseImageButton;
private UIButton tweakNinePointHelpButton;
private UIButton tweakNinePointButton;
private UIPercentDragPane borderImageOpacityPane;
private NinePointImageTweakDialogPane tweakPane;
private ImageFileChooser imageFileChooser;
private int ninePointLeft = -1;
private int ninePointTop = -1;
private int ninePointRight = -1;
private int ninePointBottom = -1;
public BorderLineAndImagePane() {
this.initComponents();
this.initLayout();
}
private void initComponents() {
borderLineCombo = new BorderLineAndImageComboBox();
borderColorPane = new UIColorButton(null) {{
setUI(createButtonUI(this));
set4ToolbarButton();
}};
imagePreviewPane = new ImagePreviewPane() {{
setImageStyle(Style.DEFAULT_STYLE);
}};
chooseImageButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image_Select_Picture"));
tweakNinePointHelpButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_border_image_help.png"));
tweakNinePointHelpButton.setUI(new BasicButtonUI());
tweakNinePointHelpButton.setBorderPainted(false);
tweakNinePointHelpButton.setBorder(null);
tweakNinePointHelpButton.setContentAreaFilled(false);
tweakNinePointHelpButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI(TWEAK_NINE_POINT_HELP_URL));
} catch (IOException | URISyntaxException ioException) {
ioException.printStackTrace();
}
}
});
tweakNinePointButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image_Config_Nine_Point_Fill"));
borderImageOpacityPane = new UIPercentDragPane();
}
private JPanel createBorderLineComposedPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
return TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Line")), this.borderLineCombo}},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, 0);
}
private JPanel createBorderColorComposedPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
return TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Color")), this.borderColorPane}},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, 0);
}
private JPanel createBorderImageComposePane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel borderedImagePreviewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
borderedImagePreviewPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
borderedImagePreviewPane.setPreferredSize(new Dimension(145, 145));
borderedImagePreviewPane.add(imagePreviewPane, BorderLayout.CENTER);
JPanel tweakNinePointComposedPane = new JPanel();
tweakNinePointComposedPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
tweakNinePointButton.setPreferredSize(new Dimension(145, 16));
tweakNinePointComposedPane.add(tweakNinePointHelpButton);
tweakNinePointComposedPane.add(tweakNinePointButton);
return TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{
{null, borderedImagePreviewPane},
{null, chooseImageButton},
{tweakNinePointComposedPane, null},
{null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))},
{null, this.borderImageOpacityPane}
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
}
private void initImageFileChooserIfNotExist() {
if (imageFileChooser == null) {
imageFileChooser = new ImageFileChooser();
imageFileChooser.setMultiSelectionEnabled(false);
}
}
protected void initNinePointTweakPaneIfNotExist() {
if (tweakPane == null) {
tweakPane = new NinePointImageTweakDialogPane();
}
}
private void initLayout() {
this.setLayout(new BorderLayout(0, IntervalConstants.INTERVAL_L1));
this.add(this.createBorderLineComposedPane(), BorderLayout.NORTH, 0);
this.add(this.createBorderColorComposedPane(), BorderLayout.CENTER, 1);
this.add(this.createBorderImageComposePane(), BorderLayout.SOUTH, 2);
getComponent(1).setVisible(false);
getComponent(2).setVisible(false);
this.borderLineCombo.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
getComponent(1).setVisible(borderLineCombo.isSelectedBorderLine());
getComponent(2).setVisible(borderLineCombo.isSelectedBorderImage());
if (!borderLineCombo.isSelectedBorderLine()) {
borderColorPane.setColor(Color.BLACK);
}
if (!borderLineCombo.isSelectedBorderImage()) {
imagePreviewPane.setImageWithSuffix(null);
}
fireStateChanged();
}
});
this.chooseImageButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
initImageFileChooserIfNotExist();
int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, DEFAULT_IMAGE_LAYOUT_STYLE, new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
Image image = imagePreviewPane.getImage();
ninePointLeft = ninePointRight = (image != null ? image.getWidth(null) / 3 : -1);
ninePointTop = ninePointBottom = (image != null ? image.getHeight(null) / 3 : -1);
borderImageOpacityPane.populateBean(1.0);
fireStateChanged();
}
}).dealWithImageFile(returnVal);
}
});
this.tweakNinePointButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
initNinePointTweakPaneIfNotExist();
if (imagePreviewPane.getImage() != null) {
BasicDialog dialog = tweakPane.showWindow(SwingUtilities.getWindowAncestor(BorderLineAndImagePane.this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
fireStateChanged();
}
});
dialog.setVisible(true);
}
}
});
}
public void populateBean(LayoutBorderStyle style) {
int borderLine = style.getBorder();
Color borderColor = style.getColor();
this.borderLineCombo.setSelectedLineStyle(borderLine);
this.borderColorPane.setColor(borderColor);
Background borderImage = style.getBorderImage();
if (borderImage instanceof ImageBackground) {
// 图片类型边框
Image image = ((ImageBackground) borderImage).getImage();
int[] ninePoint = ((ImageBackground) borderImage).getNinePoint();
if (image != null) {
this.borderLineCombo.selectBorderImage();
this.imagePreviewPane.setImageWithSuffix(((ImageBackground) borderImage).getImageWithSuffix());
this.borderImageOpacityPane.populateBean(style.getBorderImageOpacity());
if (ninePoint != null && ninePoint.length == 4 && ninePoint[0] > 0 && ninePoint[1] > 0 && ninePoint[2] > 0 && ninePoint[3] > 0) {
ninePointLeft = ninePoint[0];
ninePointTop = ninePoint[1];
ninePointRight = ninePoint[2];
ninePointBottom = ninePoint[3];
} else {
ninePointLeft = ninePointRight = image.getWidth(null) / 3;
ninePointTop = ninePointBottom = image.getHeight(null) / 3;
}
getComponent(1).setVisible(false);
getComponent(2).setVisible(true);
return;
}
}
if (borderLine == Constants.LINE_NONE) {
getComponent(1).setVisible(false);
getComponent(2).setVisible(false);
return;
} else {
getComponent(1).setVisible(true);
getComponent(2).setVisible(false);
}
this.borderLineCombo.setSelectedLineStyle(style.getBorder());
this.borderColorPane.setColor(style.getColor());
}
public void updateBean(LayoutBorderStyle style) {
style.setBorder(this.borderLineCombo.getSelectedLineStyle());
style.setColor(this.borderColorPane.getColor());
style.setBorderImage(null);
if (this.borderLineCombo.isSelectedBorderImage()) {
Image image = this.imagePreviewPane.getImage();
if (image != null) {
ImageBackground newImageBackground = new ImageFileBackground(this.imagePreviewPane.getImageWithSuffix(), Constants.IMAGE_EXTEND);
newImageBackground.setNinePoint(new int[] { ninePointLeft, ninePointTop, ninePointRight, ninePointBottom });
style.setBorderImage(newImageBackground);
style.setBorderImageOpacity((float)borderImageOpacityPane.updateBean());
}
}
}
private void fireStateChanged() {
if (uiObserverListener != null) {
uiObserverListener.doChange();
}
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.uiObserverListener = listener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
protected UIButtonUI createButtonUI(final UIColorButton uiColorButton) {
return new UIButtonUI() {
public void paint(Graphics g, JComponent c) {
UIButton b = (UIButton) c;
g.setColor(Color.black);
GraphHelper.draw(g, new RoundRectangle2D.Double(1, 1, b.getWidth() - 2, b.getHeight() - 2, 0, 0), 1);
if (b.getModel().isEnabled()) {
g.setColor(uiColorButton.getColor());
} else {
g.setColor(new Color(Utils.filterRGB(uiColorButton.getColor().getRGB(), 50)));
}
g.fillRect(2, 2, b.getWidth() - 3, b.getHeight() - 3);
}
};
}
protected static class BorderLineAndImageComboBox extends LineComboBox {
public static final int LINE_PICTURE = -1;
public final static int[] BORDER_LINE_STYLE_ARRAY = new int[] {
Constants.LINE_NONE,
LINE_PICTURE,
Constants.LINE_THIN, //1px
Constants.LINE_MEDIUM, //2px
Constants.LINE_THICK, //3px
};
public BorderLineAndImageComboBox() {
super(BORDER_LINE_STYLE_ARRAY);
}
@Override
protected String toStringFromStyle(int style) {
if (style == LINE_PICTURE) {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image");
}
return super.toStringFromStyle(style);
}
public boolean isSelectedBorderLine() {
return getSelectedIndex() > 1;
}
public boolean isSelectedBorderImage() {
return getSelectedIndex() == 1;
}
public void selectBorderImage() {
this.setSelectedIndex(1);
}
}
private class NinePointImageTweakDialogPane extends BasicPane {
private final NinePointLinePreviewPane previewPane = new NinePointLinePreviewPane();
public NinePointImageTweakDialogPane() {
this.initComponents();
}
private void initComponents() {
setLayout(new BorderLayout());
setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image_Config_Nine_Point_Fill_Preview")));
JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane();
content.setBorder(BorderFactory.createEmptyBorder(
IntervalConstants.INTERVAL_W1,
IntervalConstants.INTERVAL_W1,
IntervalConstants.INTERVAL_W1,
IntervalConstants.INTERVAL_W1));
content.add(previewPane);
previewPane.setPreferredSize(new Dimension(611, 457));
add(content, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Border_Image_Config_Nine_Point_Fill");
}
}
private class NinePointLinePreviewPane extends JPanel implements MouseMotionListener, MouseListener {
private final BufferedImage transparentImage = IOUtils.readImage("/com/fr/design/images/transparent_background.jpg");
public final Color PATCH_COLOR = new Color(0, 0, 0, 38);
public final Color DIVIDER_COLOR = new Color(250, 250, 250);
public final Color TEXT_COLOR = Color.WHITE;
public final int PADDING = 15;
private int imgWidth;
private int imgHeight;
private int scaleImgWidth;
private int scaleImgHeight;
private int scaleImgX;
private int scaleImgY;
private double scale = 1.0;
public NinePointLinePreviewPane() {
this.addMouseMotionListener(this);
this.addMouseListener(this);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(transparentImage, 0, 0, getWidth(), getHeight(), null);
Image image = imagePreviewPane.getImage();
imgWidth = image.getWidth(null);
imgHeight = image.getHeight(null);
int autoFixAreaWidth = getWidth() - 2 * PADDING;
int autoFixAreaHeight = getHeight() - 2 * PADDING;
int autoFixAreaX = PADDING;
int autoFixAreaY = PADDING;
if (imgWidth / imgHeight > autoFixAreaWidth / autoFixAreaHeight) {
scaleImgWidth = autoFixAreaWidth;
scaleImgHeight = (int) (1.0F * scaleImgWidth * imgHeight / imgWidth);
scaleImgX = autoFixAreaX;
scaleImgY = (autoFixAreaHeight - scaleImgHeight) / 2 + autoFixAreaY; // 垂直居中
scale = 1.0 * scaleImgWidth / imgWidth;
} else {
scaleImgHeight = autoFixAreaHeight;
scaleImgWidth = (int) (1.0F * scaleImgHeight * imgWidth / imgHeight);
scaleImgX = (autoFixAreaWidth - scaleImgWidth) / 2 + autoFixAreaX; // 水平居中
scaleImgY = autoFixAreaY;
scale = 1.0 * scaleImgHeight / imgHeight;
}
g2d.drawImage(image, scaleImgX, scaleImgY, scaleImgWidth, scaleImgHeight, null);
int scaleLeft = (int) (ninePointLeft * scale);
int scaleTop = (int) (ninePointTop * scale);
int scaleRight = (int) (ninePointRight * scale);
int scaleBottom = (int) (ninePointBottom * scale);
g2d.setColor(PATCH_COLOR);
// draw horizontal patch
GraphDrawHelper.fillRect(g2d, 0, scaleImgY + scaleTop, getWidth(), scaleImgHeight - scaleTop - scaleBottom);
// draw vertical patch
GraphDrawHelper.fillRect(g2d, scaleImgX + scaleLeft, 0,scaleImgWidth - scaleLeft - scaleRight, getHeight());
g2d.setColor(DIVIDER_COLOR);
// draw top divider
GraphDrawHelper.drawLine(g2d, 0, scaleImgY + scaleTop, getWidth(), scaleImgY + scaleTop);
// draw bottom divider
GraphDrawHelper.drawLine(g2d, 0, scaleImgY + scaleImgHeight - scaleBottom, getWidth(), scaleImgY + scaleImgHeight - scaleBottom);
// draw left divider
GraphDrawHelper.drawLine(g2d, scaleImgX + scaleLeft, 0, scaleImgX + scaleLeft, getHeight());
// draw right divider
GraphDrawHelper.drawLine(g2d, scaleImgX + scaleImgWidth - scaleRight, 0, scaleImgX + scaleImgWidth - scaleRight, getHeight());
g2d.setColor(TEXT_COLOR);
// draw nine point info
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointTop), scaleImgX + (scaleImgWidth + scaleLeft - scaleRight) / 2.0, (scaleImgY + scaleTop) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointBottom), scaleImgX + scaleLeft + (scaleImgWidth - scaleLeft - scaleRight) / 2.0, scaleImgY + scaleImgHeight - (scaleBottom - PADDING) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointLeft), (scaleImgX + scaleLeft) / 2.0, scaleImgY + (scaleImgHeight + scaleTop - scaleBottom) / 2.0);
GraphDrawHelper.drawString(g2d, Integer.toString(ninePointRight), scaleImgX + scaleImgWidth - (scaleRight - PADDING) / 2.0, scaleImgY + (scaleImgHeight + scaleTop - scaleBottom) / 2.0);
}
@Override
public void mouseDragged(MouseEvent e) {
int x = e.getX();
int y = e.getY();
int cursorType = getCursor().getType();
switch (cursorType) {
case Cursor.W_RESIZE_CURSOR: {
int nextLeft = (int) ((x - scaleImgX) / scale);
if (1 <= nextLeft && nextLeft < imgWidth - ninePointRight) {
ninePointLeft = nextLeft;
repaint();
}
return;
}
case Cursor.E_RESIZE_CURSOR: {
int nextRight = (int) ((scaleImgX + scaleImgWidth - x) / scale);
if (1 <= nextRight && nextRight < imgWidth - ninePointLeft) {
ninePointRight = nextRight;
repaint();
}
return;
}
case Cursor.N_RESIZE_CURSOR: {
int nextTop = (int) ((y - scaleImgY) / scale);
if (1 <= nextTop && nextTop < imgHeight - ninePointBottom) {
ninePointTop = nextTop;
repaint();
}
return;
}
case Cursor.S_RESIZE_CURSOR: {
int nextBottom = (int) ((scaleImgY + scaleImgHeight - y) / scale);
if (1 <= nextBottom && nextBottom < imgHeight - ninePointTop) {
ninePointBottom = nextBottom;
repaint();
}
}
}
}
@Override
public void mouseMoved(MouseEvent e) {
boolean needRepaint;
int x = e.getX();
int y = e.getY();
double scaleLeft = ninePointLeft * scale;
double scaleTop = ninePointTop * scale;
double scaleRight = ninePointRight * scale;
double scaleBottom = ninePointBottom * scale;
// determine cursor
int cursorType = Cursor.DEFAULT_CURSOR;
boolean hoveringLeftDivider = Math.abs(x - (scaleImgX + scaleLeft)) < 2;
boolean hoveringRightDivider = Math.abs(x - (scaleImgX + scaleImgWidth - scaleRight)) < 2;
boolean hoveringTopDivider = Math.abs(y - (scaleImgY + scaleTop)) < 2;
boolean hoveringBottomDivider = Math.abs(y - (scaleImgY + scaleImgHeight - scaleBottom)) < 2;
if (hoveringLeftDivider) {
cursorType = Cursor.W_RESIZE_CURSOR;
} else if (hoveringRightDivider) {
cursorType = Cursor.E_RESIZE_CURSOR;
} else if (hoveringTopDivider) {
cursorType = Cursor.N_RESIZE_CURSOR;
} else if (hoveringBottomDivider) {
cursorType = Cursor.S_RESIZE_CURSOR;
}
needRepaint = getCursor().getType() != cursorType;
this.setCursor(Cursor.getPredefinedCursor(cursorType));
if (needRepaint) {
repaint();
}
}
@Override
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
repaint();
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
}

27
designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java

@ -0,0 +1,27 @@
/*
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.gui.xpane;
import com.fr.form.ui.LayoutBorderStyle;
import javax.swing.*;
/**
* CardTagLayoutBorderPane Pane.
*/
public class CardTagLayoutStylePane extends LayoutStylePane {
@Override
protected JPanel createTitleStylePane(){
return null;
}
@Override
public void updateTitle(LayoutBorderStyle style) {
}
@Override
protected void populateTitle() { }
}

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

@ -0,0 +1,502 @@
package com.fr.design.gui.xpane;
import com.fr.base.GraphHelper;
import com.fr.base.Utils;
import com.fr.base.svg.IconUtils;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.UIPercentDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
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.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.style.BackgroundSpecialPane;
import com.fr.design.gui.style.FRFontPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.Background;
import com.fr.general.FRFont;
import com.fr.general.IOUtils;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
/**
* @author Starryi
* @version 10.0.18
* Created by Starryi on 2021/6/25
*
* 可配置图片类型边框的样式设置面板
*/
public class LayoutStylePane extends BasicBeanPane<LayoutBorderStyle> {
public static final String[] BORDER_STYLE = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Common"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Shadow")
};
private static final Dimension BUTTON_SIZE = new Dimension(20, 20);
private static final int SETTING_LABEL_WIDTH = 60;
protected LayoutBorderStyle style = new LayoutBorderStyle();
//渲染风格:有无阴影
protected UIComboBox borderStyleCombo;
// 含图片类型边框的边框配置面板(图片类型边框 + 阴影时存在默认的阴影颜色)
protected BorderLineAndImagePane borderLineAndImagePane;
//边框圆角或圆角裁剪
protected UISpinner cornerSpinner;
//主体背景
protected BackgroundSpecialPane backgroundPane;
//主体背景透明度
protected UIPercentDragPane backgroundOpacityPane;
// 标题可见
protected UICheckBox titleVisibleCheckbox;
//标题文字内容
protected TinyFormulaPane titleTextPane;
//标题字体格式
protected UIComboBox titleFontFamilyComboBox;
//标题字体大小
protected UIComboBox titleFontSizeComboBox;
//标题字体颜色
protected UIColorButton titleFontColorSelectPane;
//标题字体特殊效果:粗体、斜体、下划线
private UIToggleButton titleFontBoldButton;
private UIToggleButton titleFontItalicButton;
private UIToggleButton titleFontUnderlineButton;
private LineComboBox titleFontUnderlineCombo;
// 标题图文混排
protected TitleInsetImagePane titleInsetImagePane;
//对齐方式
protected UIButtonGroup titleAlignPane;
//标题整体背景
protected BackgroundSpecialPane titleBackgroundPane;
//标题背景透明度
protected UIPercentDragPane titleBackgroundOpacityPane;
public LayoutStylePane() {
this.initLayout();
}
protected void initLayout() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean currentIsRootLayout = currentEditingTemplate != null && !currentEditingTemplate.isJWorkBook() && ((JForm)currentEditingTemplate).isSelectRootPane();
JPanel titlePane = createTitleStylePane();
if (titlePane != null) {
container.add(titlePane, BorderLayout.NORTH);
if (currentIsRootLayout) {
titlePane.setVisible(false);
}
}
//界面上表单主体只有背景和透明度可以设置
JPanel mainStylePane = currentIsRootLayout ? createMainStylePane4RootLayout() : createMainStylePane4WidgetLayout();
if (mainStylePane != null) {
container.add(mainStylePane, BorderLayout.CENTER);
}
this.add(container, BorderLayout.CENTER);
}
protected void initMainComponents() {
borderStyleCombo = new UIComboBox(BORDER_STYLE);
borderLineAndImagePane = new BorderLineAndImagePane();
cornerSpinner = new UISpinner(0,1000,1,0);
backgroundPane = new BackgroundSpecialPane();
backgroundOpacityPane = new UIPercentDragPane();
}
protected JPanel createMainStylePane4WidgetLayout() {
initMainComponents();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
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_Render_Style")), borderStyleCombo},
{this.borderLineAndImagePane, null},
{this.createMainBackgroundAndOpacityPane(), null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius")), cornerSpinner},
},
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 JPanel createMainStylePane4RootLayout() {
initMainComponents();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Frame_Style")), null},
{this.createMainBackgroundAndOpacityPane(), 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 JPanel createMainBackgroundAndOpacityPane() {
return createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Body_Background"),
this.backgroundPane,
this.backgroundOpacityPane);
}
protected void initTitleComponents() {
titleVisibleCheckbox = new UICheckBox();
titleTextPane = new TinyFormulaPane();
titleFontFamilyComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
titleFontFamilyComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Family"));
titleFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
titleFontSizeComboBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size"));
titleFontColorSelectPane = new UIColorButton();
titleFontColorSelectPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground"));
titleFontColorSelectPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Foreground"));
titleFontBoldButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
titleFontBoldButton.setPreferredSize(BUTTON_SIZE);
titleFontBoldButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold"));
titleFontBoldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Bold"));
titleFontItalicButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
titleFontItalicButton.setPreferredSize(BUTTON_SIZE);
titleFontItalicButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic"));
titleFontItalicButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Italic"));
titleFontUnderlineButton = new UIToggleButton(IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"));
titleFontUnderlineButton.setPreferredSize(BUTTON_SIZE);
titleFontUnderlineButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline"));
titleFontUnderlineButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Underline"));
titleFontUnderlineCombo = new LineComboBox(UIConstants.BORDER_LINE_STYLE_ARRAY);
titleFontUnderlineCombo.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style"));
titleInsetImagePane = new TitleInsetImagePane();
titleAlignPane = new UIButtonGroup<Integer>(
new Icon[] {
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"),
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"),
IconUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png")
},
new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT});
titleAlignPane.setAllToolTips(
new String[] {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")
});
titleBackgroundPane = new BackgroundSpecialPane();
titleBackgroundOpacityPane = new UIPercentDragPane();
}
protected JPanel createTitleStylePane() {
initTitleComponents();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p,p,p,p,p,p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
final JPanel bottomPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Content")), titleTextPane},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Format")), titleFontFamilyComboBox},
{null, createTitleFontButtonPane()},
{titleInsetImagePane, null},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Text_Align")), titleAlignPane},
{this.createTitleBackgroundAndOpacityPane(), null},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1);
bottomPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
bottomPane.setVisible(false);
JPanel visibleComposedPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
titleVisibleCheckbox.setSelected(false);
visibleComposedPane.add(titleVisibleCheckbox, BorderLayout.WEST);
visibleComposedPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Visible")), BorderLayout.CENTER);
JPanel topPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] {
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title")), null},
{visibleComposedPane, null}
}, new double[]{p, p}, new double[]{SETTING_LABEL_WIDTH, p}, IntervalConstants.INTERVAL_L1);
topPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(new BottomLineBorder());
container.add(topPane, BorderLayout.NORTH);
container.add(bottomPane, BorderLayout.CENTER);
titleVisibleCheckbox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
bottomPane.setVisible(titleVisibleCheckbox.isSelected());
}
});
return container;
}
protected JPanel createTitleFontButtonPane(){
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {f, p, p, p, p};
JPanel buttonPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][] {
{titleFontSizeComboBox, titleFontColorSelectPane, titleFontItalicButton, titleFontBoldButton, titleFontUnderlineButton},
}, rowSize, columnSize, IntervalConstants.INTERVAL_W0);
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
containerPane.add(buttonPane, BorderLayout.NORTH);
containerPane.add(titleFontUnderlineCombo, BorderLayout.CENTER);
titleFontUnderlineCombo.setVisible(false);
titleFontUnderlineButton.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
titleFontUnderlineCombo.setVisible(titleFontUnderlineButton.isSelected());
}
});
return containerPane;
}
protected JPanel createTitleBackgroundAndOpacityPane() {
return createBackgroundAndOpacityPane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Background"),
titleBackgroundPane,
titleBackgroundOpacityPane);
}
@Override
public LayoutBorderStyle updateBean() {
LayoutBorderStyle style = new LayoutBorderStyle();
updateMain(style);
updateTitle(style);
return style;
}
protected void updateMain(LayoutBorderStyle style) {
if (borderStyleCombo != null) {
style.setBorderStyle(borderStyleCombo.getSelectedIndex());
}
if (cornerSpinner != null) {
style.setBorderRadius((int) cornerSpinner.getValue());
}
if (borderLineAndImagePane != null) {
borderLineAndImagePane.updateBean(style);
}
if (backgroundPane != null) {
style.setBackground(backgroundPane.update());
}
if (backgroundOpacityPane != null) {
style.setAlpha((float)backgroundOpacityPane.updateBean());
}
}
protected void updateTitle(LayoutBorderStyle style) {
style.setType(titleVisibleCheckbox != null && titleVisibleCheckbox.isSelected() ? LayoutBorderStyle.TITLE : LayoutBorderStyle.STANDARD);
TitlePacker title = style.getTitle() == null ? new WidgetTitle() : style.getTitle();
title.setTextObject(titleTextPane.updateBean());
FRFont frFont = title.getFrFont();
frFont = frFont.applySize((Integer) titleFontSizeComboBox.getSelectedItem());
frFont = frFont.applyName(titleFontFamilyComboBox.getSelectedItem().toString());
frFont = frFont.applyForeground(titleFontColorSelectPane.getColor());
frFont = updateTitleFontItalicBold(frFont);
int line = titleFontUnderlineButton.isSelected() ? this.titleFontUnderlineCombo.getSelectedLineStyle() : Constants.LINE_NONE;
frFont = frFont.applyUnderline(line);
title.setFrFont(frFont);
title.setPosition((Integer) titleAlignPane.getSelectedItem());
titleInsetImagePane.updateBean(title);
title.setBackground(titleBackgroundPane.update());
title.setBackgroundOpacity((float)titleBackgroundOpacityPane.updateBean());
style.setTitle(title);
}
private FRFont updateTitleFontItalicBold(FRFont frFont) {
int italic_bold = frFont.getStyle();
boolean isItalic = italic_bold == Font.ITALIC || italic_bold == (Font.BOLD + Font.ITALIC);
boolean isBold = italic_bold == Font.BOLD || italic_bold == (Font.BOLD + Font.ITALIC);
if (titleFontItalicButton.isSelected() && !isItalic) {
italic_bold += Font.ITALIC;
} else if (!titleFontItalicButton.isSelected() && isItalic) {
italic_bold -= Font.ITALIC;
}
frFont = frFont.applyStyle(italic_bold);
if (titleFontBoldButton.isSelected() && !isBold) {
italic_bold += Font.BOLD;
} else if (!titleFontBoldButton.isSelected() && isBold) {
italic_bold -= Font.BOLD;
}
frFont = frFont.applyStyle(italic_bold);
return frFont;
}
@Override
public void populateBean(LayoutBorderStyle style) {
if(this.style == null) {
this.style = new LayoutBorderStyle();
}
this.style.setStyle(style);
populateMain();
populateTitle();
}
protected void populateMain() {
if (this.borderStyleCombo != null) {
this.borderStyleCombo.setSelectedIndex(style.getBorderStyle());
}
if (this.borderLineAndImagePane != null) {
this.borderLineAndImagePane.populateBean(style);
}
if (this.backgroundPane != null) {
this.backgroundPane.populateBean(style.getBackground());
if (this.backgroundOpacityPane != null) {
this.backgroundOpacityPane.populateBean(style.getAlpha());
}
}
if (this.cornerSpinner != null) {
this.cornerSpinner.setValue(style.getBorderRadius());
}
}
protected void populateTitle() {
TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle();
widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle;
titleVisibleCheckbox.setSelected(style.getType() != LayoutBorderStyle.STANDARD);
this.titleTextPane.populateBean(widgetTitle.getTextObject().toString());
FRFont frFont = widgetTitle.getFrFont();
this.titleFontSizeComboBox.setSelectedItem(frFont.getSize());
this.titleFontFamilyComboBox.setSelectedItem(frFont.getFamily());
this.titleFontColorSelectPane.setColor(frFont.getForeground());
this.titleFontColorSelectPane.repaint();
titleFontBoldButton.setSelected(frFont.isBold());
titleFontItalicButton.setSelected(frFont.isItalic());
int line = frFont.getUnderline();
if (line == Constants.LINE_NONE) {
titleFontUnderlineButton.setSelected(false);
titleFontUnderlineCombo.setVisible(false);
} else {
titleFontUnderlineButton.setSelected(true);
titleFontUnderlineCombo.setVisible(true);
this.titleFontUnderlineCombo.setSelectedLineStyle(line);
}
titleAlignPane.setSelectedItem(widgetTitle.getPosition());
titleInsetImagePane.populateBean(widgetTitle);
titleBackgroundPane.populateBean(widgetTitle.getBackground());
titleBackgroundOpacityPane.populateBean(widgetTitle.getBackgroundOpacity());
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style");
}
private static JPanel createBackgroundAndOpacityPane(String name, BackgroundSpecialPane backgroundPane, UIPercentDragPane opacityPane) {
JPanel container = new JPanel();
container.setLayout(new BorderLayout(0, 6));
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {SETTING_LABEL_WIDTH, f};
// 确保BackgroundSpecialPane高度变化时,Label依然保持与其顶部对齐
JPanel backgroundLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
backgroundLabelPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
backgroundLabelPane.add(new UILabel(name), BorderLayout.NORTH);
JPanel backgroundComposedPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{
{backgroundLabelPane, backgroundPane}
},
new double[]{p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
JPanel opacityComposedPane = TableLayoutHelper.createGapTableLayoutPane(
new JComponent[][]{
{new UILabel(""), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget-Style_Alpha"))},
{new UILabel(""), opacityPane}
},
new double[]{p, p}, columnSize, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1);
container.add(backgroundComposedPane, BorderLayout.NORTH, 0);
container.add(opacityComposedPane, BorderLayout.CENTER, 1);
opacityComposedPane.setVisible(false);
backgroundPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
Background background = backgroundPane.update();
opacityComposedPane.setVisible(background != null);
}
});
return container;
}
protected static class BottomLineBorder extends LineBorder {
public BottomLineBorder() {
super(Color.lightGray, 1);
}
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor);
GraphHelper.drawLine(g, 0, height, width, height, 1);
g2d.setColor(oldColor);
}
}
}

258
designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java

@ -0,0 +1,258 @@
package com.fr.design.gui.xpane;
import com.fr.base.Style;
import com.fr.base.background.ImageBackground;
import com.fr.base.background.ImageFileBackground;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.frpane.ImgChooseWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.backgroundpane.ImagePreviewPane;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.widget.ui.designer.component.UIBoundSpinner;
import com.fr.form.ui.WidgetTitle;
import com.fr.general.Background;
import com.fr.general.IOUtils;
import com.fr.general.ImageWithSuffix;
import com.fr.general.act.TitlePacker;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Starryi
* @version 10.0.18
* Created by Starryi on 2021/7/3
*/
public class TitleInsetImagePane extends JPanel implements UIObserver {
private final int SETTING_LABEL_WIDTH = 60;
private final int DELETE_BUTTON_SIZE = 24;
private final int IMAGE_PREVIEW_SIZE = 145;
private final Style DEFAULT_IMAGE_LAYOUT_STYLE = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_DEFAULT);
private final int DEFAULT_INSET_LOCATION_INDEX = 0;
private final int DEFAULT_INSET_PADDING = 10;
private UIObserverListener uiObserverListener;
private UIButton imageChooseButton;
private UIButton imageDeleteButton;
private ImagePreviewPane imagePreviewPane;
private UIButtonGroup<Integer> imageLocationPane;
private UISpinner imagePaddingPane;
private ImageFileChooser imageFileChooser;
public TitleInsetImagePane() {
this.initComponents();
this.initLayout();
}
private JPanel createImageChooseComposedPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
return TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset")), this.imageChooseButton},
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1);
}
private JPanel createImageContentComposedPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p, p};
double[] columnSize = {SETTING_LABEL_WIDTH, f};
JPanel deletableImagePreviewPane = new JPanel();
deletableImagePreviewPane.setLayout(null);
deletableImagePreviewPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5));
deletableImagePreviewPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE));
imagePreviewPane.setBounds(0, 0, IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE);
imageDeleteButton.setBounds(IMAGE_PREVIEW_SIZE - DELETE_BUTTON_SIZE, 0, DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE);
deletableImagePreviewPane.add(imageDeleteButton, 0);
deletableImagePreviewPane.add(imagePreviewPane, 1);
return TableLayoutHelper.createCommonTableLayoutPane(
new JComponent[][]{
{null, deletableImagePreviewPane},
{null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Location"))},
{null, this.imageLocationPane},
{null, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Padding"))},
{null, this.imagePaddingPane}
},
rowSize, columnSize, IntervalConstants.INTERVAL_L1);
}
private void initImageFileChooserIfNotExist() {
if (imageFileChooser == null) {
imageFileChooser = new ImageFileChooser();
imageFileChooser.setMultiSelectionEnabled(false);
}
}
private void initComponents() {
imageChooseButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_choose_inset.png"));
imageDeleteButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_delete_inset.png"));
imageDeleteButton.setUI(new BasicButtonUI());
imageDeleteButton.setOpaque(true);
imageDeleteButton.setBorderPainted(false);
imageDeleteButton.setBorder(null);
imageDeleteButton.setFocusPainted(false);
imageDeleteButton.setContentAreaFilled(true);
imageDeleteButton.setPreferredSize(new Dimension(DELETE_BUTTON_SIZE, DELETE_BUTTON_SIZE));
imageDeleteButton.setBackground(new Color(51, 51, 51));
imagePreviewPane = new ImagePreviewPane();
imagePreviewPane.setImageStyle(DEFAULT_IMAGE_LAYOUT_STYLE);
imagePreviewPane.setPreferredSize(new Dimension(IMAGE_PREVIEW_SIZE, IMAGE_PREVIEW_SIZE));
imageLocationPane = new UIButtonGroup<Integer>(new Icon[][]{
{
IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_left_selected.png"),
IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_left_unselected.png")
},
{
IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_both_selected.png"),
IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_both_unselected.png")
},
{
IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_right_selected.png"),
IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_inset_right_unselected.png")
},
});
imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX);
imageLocationPane.setAllToolTips(new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Left_Tooltip"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Both_Tooltip"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Title_Inset_Relative_Right_Tooltip"),
});
imagePaddingPane = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, WidgetTitle.DEFAULT_INSET_PADDING);
imagePaddingPane.setValue(DEFAULT_INSET_PADDING);
}
private void initLayout() {
this.setLayout(new BorderLayout(0, IntervalConstants.INTERVAL_L1));
add(createImageChooseComposedPane(), BorderLayout.NORTH, 0);
add(createImageContentComposedPane(), BorderLayout.CENTER, 1);
getComponent(1).setVisible(false);
this.imageChooseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
initImageFileChooserIfNotExist();
int returnVal = imageFileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
ImgChooseWrapper.getInstance(imagePreviewPane, imageFileChooser, DEFAULT_IMAGE_LAYOUT_STYLE, new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (!getComponent(1).isVisible()) {
imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX);
imagePaddingPane.setValue(DEFAULT_INSET_PADDING);
getComponent(1).setVisible(true);
}
fireStateChanged();
}
}).dealWithImageFile(returnVal);
}
});
this.imageDeleteButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
imagePreviewPane.setImageWithSuffix(null);
imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX);
imagePaddingPane.setValue(DEFAULT_INSET_PADDING);
getComponent(1).setVisible(false);
fireStateChanged();
}
});
}
public void populateBean(TitlePacker packer) {
Background insetImage = packer.getInsetImage();
if (insetImage instanceof ImageBackground) {
ImageWithSuffix image = ((ImageBackground) insetImage).getImageWithSuffix();
if (image != null) {
this.imagePreviewPane.setImageWithSuffix(image);
if (!packer.isInsetRelativeTextLeft()) {
this.imageLocationPane.setSelectedIndex(2);
} else if (!packer.isInsetRelativeTextRight()) {
this.imageLocationPane.setSelectedIndex(0);
} else {
this.imageLocationPane.setSelectedIndex(1);
}
this.imagePaddingPane.setValue(packer.getInsetImagePadding());
getComponent(1).setVisible(true);
return;
}
}
this.imagePreviewPane.setImageWithSuffix(null);
this.imageLocationPane.setSelectedIndex(DEFAULT_INSET_LOCATION_INDEX);
this.imagePaddingPane.setValue(DEFAULT_INSET_PADDING);
getComponent(1).setVisible(false);
}
public void updateBean(TitlePacker packer) {
Image image = imagePreviewPane.getImageWithSuffix();
if (image != null) {
packer.setInsetImage(new ImageFileBackground(image, Constants.IMAGE_DEFAULT));
int imageLocationIndex = this.imageLocationPane.getSelectedIndex();
packer.setInsetRelativeTextLeft(imageLocationIndex == 0 || imageLocationIndex == 1);
packer.setInsetRelativeTextRight(imageLocationIndex == 2 || imageLocationIndex == 1);
packer.setInsetImagePadding((int) this.imagePaddingPane.getValue());
} else {
packer.setInsetImage(null);
packer.setInsetImagePadding(WidgetTitle.DEFAULT_INSET_PADDING);
packer.setInsetRelativeTextLeft(WidgetTitle.DEFAULT_INSET_LEFT);
packer.setInsetRelativeTextRight(WidgetTitle.DEFAULT_INSET_RIGHT);
}
}
private void fireStateChanged() {
if (uiObserverListener != null) {
uiObserverListener.doChange();
}
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.uiObserverListener = listener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
}

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

@ -475,7 +475,12 @@ public class EditingMouseListener extends MouseInputAdapter {
if (DesignerMode.isAuthorityEditing()) {
return;
}
if ((e.isShiftDown() || InputEventBaseOnOS.isControlDown(e)) && !stateModel.isSelecting()) {
boolean shiftSelecting = e.isShiftDown();
boolean ctrlSelecting = InputEventBaseOnOS.isControlDown(e);
int currentCursorType = this.designer.getCursor().getType();
boolean shiftResizing = e.isShiftDown() && ( Cursor.SW_RESIZE_CURSOR <= currentCursorType && currentCursorType <= Cursor.E_RESIZE_CURSOR);
if ((shiftSelecting || ctrlSelecting) && !shiftResizing && !stateModel.isSelecting()) {
stateModel.startSelecting(e);
}
// 如果当前是左键拖拽状态,拖拽组件

12
designer-form/src/main/java/com/fr/design/mainframe/FormEditorKeyListener.java

@ -27,7 +27,11 @@ public class FormEditorKeyListener extends KeyAdapter{
@Override
public void keyPressed(KeyEvent e) {
if(e.isShiftDown() || InputEventBaseOnOS.isControlDown(e)) {
boolean shiftSelecting = e.isShiftDown();
boolean ctrlSelecting = InputEventBaseOnOS.isControlDown(e);
int currentCursorType = this.designer.getCursor().getType();
boolean shiftResizing = e.isShiftDown() && ( Cursor.SW_RESIZE_CURSOR <= currentCursorType && currentCursorType <= Cursor.E_RESIZE_CURSOR);
if((shiftSelecting || ctrlSelecting) && !shiftResizing) {
designer.setCursor(ADDCURSOR);
}
int code = e.getKeyCode();
@ -57,7 +61,11 @@ public class FormEditorKeyListener extends KeyAdapter{
}
public void keyReleased(KeyEvent e) {
if(!(e.isShiftDown() || InputEventBaseOnOS.isControlDown(e))) {
boolean shiftSelecting = e.isShiftDown();
boolean ctrlSelecting = InputEventBaseOnOS.isControlDown(e);
int currentCursorType = this.designer.getCursor().getType();
boolean shiftResizing = e.getKeyCode() == KeyEvent.VK_SHIFT && ( Cursor.SW_RESIZE_CURSOR <= currentCursorType && currentCursorType <= Cursor.E_RESIZE_CURSOR);
if(!(shiftSelecting || ctrlSelecting) && !shiftResizing) {
designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
if (moved) {

13
designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRAbsoluteLayoutAdapter;
import com.fr.design.designer.beans.location.Direction;
import com.fr.design.designer.creator.XComponent;
import com.fr.design.designer.creator.XCreator;
@ -287,6 +288,18 @@ public class FormSelection {
}
}
public boolean isCreatorAspectRatioLockedInAbsLayout(FormDesigner designer) {
for (XCreator creator : selection) {
LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(designer, creator);
if (layoutAdapter instanceof FRAbsoluteLayoutAdapter) {
if (creator.toData().isAspectRatioLocked()) {
return true;
}
}
}
return false;
}
/**
* @Description 重置报表块缩略图
* @param: creator

16
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java

@ -25,6 +25,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.widget.DataModify;
import com.fr.design.widget.FormWidgetDefinePaneFactoryBase;
import com.fr.design.widget.Operator;
@ -67,10 +68,6 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele
this.designer = designer;
initComponents();
initDefinePane();
widgetBoundPane = createWidgetBoundPane(xCreator);
if (widgetBoundPane != null) {
attriCardPane.add(widgetBoundPane, BorderLayout.CENTER);
}
}
public XLayoutContainer getParent(XCreator source) {
@ -162,10 +159,15 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele
jPanel.add(uiExpandablePane, BorderLayout.NORTH);
widgetBoundPane = createWidgetBoundPane(xCreator);
if (widgetBoundPane != null) {
attriCardPane.add(widgetBoundPane, BorderLayout.NORTH);
}
}
private static void freshPropertyMode(XCreator xCreator) {
if (!(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate() instanceof JForm)) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (!(jTemplate instanceof JForm) && jTemplate.isUpMode()) {
if (xCreator instanceof XWParameterLayout) {
EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA);
} else {
@ -187,7 +189,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele
JComponent jComponent = definePane.toSwingComponent();
attriCardPane.add(jComponent, BorderLayout.NORTH);
attriCardPane.add(jComponent, BorderLayout.CENTER);
currentEditorDefinePane = definePane;
}
@ -232,7 +234,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele
UITextField widgetNameField = widgetPropertyPane.getWidgetNameField();
String toSetWidgetName = widgetNameField.getText();
String currentWidgetName = widget.getWidgetName();
boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName);
boolean exist = designer.getTarget().isNameExist(toSetWidgetName, widget) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName);
if (toSetWidgetName.isEmpty()) {
widgetNameField.setText(currentWidgetName);
return;

6
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java

@ -9,8 +9,7 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.design.widget.WidgetBoundsPaneFactory;
import com.fr.form.ui.container.WLayout;
import java.awt.Rectangle;
import java.awt.*;
/**
@ -30,11 +29,12 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane {
y = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
ratioLockedButton = new AspectRatioLockedButton(width, height, creator);
x.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
y.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
width.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
height.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
this.add(WidgetBoundsPaneFactory.createAbsoluteBoundsPane(x, y, width, height, WidgetBoundsPaneFactory.NameAttribute.WIDGET));
this.add(WidgetBoundsPaneFactory.createAbsoluteBoundsPane(x, y, width, height, ratioLockedButton, WidgetBoundsPaneFactory.NameAttribute.WIDGET));
}
@Override

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

@ -11,19 +11,31 @@ import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardTagLayout;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.widget.WidgetBoundsPaneFactory;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.general.IOUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.awt.Rectangle;
import static com.fr.design.i18n.Toolkit.i18nText;
/**
@ -37,6 +49,7 @@ public class WidgetBoundPane extends BasicPane {
protected XCreator creator;
protected UISpinner width;
protected UISpinner height;
protected AspectRatioLockedButton ratioLockedButton;
public WidgetBoundPane(XCreator source) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -59,13 +72,20 @@ public class WidgetBoundPane extends BasicPane {
public void initBoundPane() {
width = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
height = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
width.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
height.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"));
width.setGlobalName(i18nText("Fine-Design_Form_Coords_And_Size"));
height.setGlobalName(i18nText("Fine-Design_Form_Coords_And_Size"));
if (creator.acceptType(XWCardLayout.class)) {
width.setEnabled(false);
height.setEnabled(false);
}
this.add(WidgetBoundsPaneFactory.createBoundsPane(width, height));
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jTemplate.isJWorkBook() || !((JForm)jTemplate).isSelectRootPane()) {
ratioLockedButton = new AspectRatioLockedButton(width, height, creator);
ratioLockedButton.setLockEnabled(false);
}
this.add(WidgetBoundsPaneFactory.createBoundsPane(width, height, ratioLockedButton));
}
@ -82,6 +102,9 @@ public class WidgetBoundPane extends BasicPane {
Rectangle bounds = new Rectangle(creator.getBounds());
width.setValue(bounds.width);
height.setValue(bounds.height);
if (ratioLockedButton != null) {
ratioLockedButton.populate(creator);
}
}
public void fix() {
@ -97,6 +120,9 @@ public class WidgetBoundPane extends BasicPane {
if (bounds.height != h) {
limitHeight(wabs, h, bounds, rec);
}
if (ratioLockedButton != null) {
ratioLockedButton.setLocked(creator.toData().isAspectRatioLocked());
}
}
@ -116,11 +142,11 @@ public class WidgetBoundPane extends BasicPane {
PaddingMargin margin = wabs.getMargin();
if (bounds.width != w) {
if (bounds.width == rec.width - margin.getLeft() - margin.getRight()) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds"));
FineJOptionPane.showMessageDialog(null, i18nText("Fine-Design_Form_Beyond_Bounds"));
width.setValue(bounds.width);
return;
} else if (w < minWidth) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Width") + Integer.toString(minWidth));
FineJOptionPane.showMessageDialog(null, i18nText("Fine-Design_Form_Min_Width") + Integer.toString(minWidth));
width.setValue(bounds.width);
return;
}
@ -137,11 +163,11 @@ public class WidgetBoundPane extends BasicPane {
int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling());
if (bounds.height != h) {
if (bounds.height == rec.height - margin.getTop() - margin.getBottom()) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds"));
FineJOptionPane.showMessageDialog(null, i18nText("Fine-Design_Form_Beyond_Bounds"));
height.setValue(bounds.height);
return;
} else if (h < minHeight) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Height") + Integer.toString(minHeight));
FineJOptionPane.showMessageDialog(null, i18nText("Fine-Design_Form_Min_Height") + Integer.toString(minHeight));
height.setValue(bounds.height);
return;
}
@ -165,4 +191,109 @@ public class WidgetBoundPane extends BasicPane {
}
protected static class AspectRatioLockedButton extends UIButton {
private final Icon enabledLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_lock_enabled.png");
private final Icon disabledLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_lock_disabled.png");
private final Icon enabledUnLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_unlock_enabled.png");
private final Icon disabledUnLocked = IOUtils.readIcon("/com/fr/design/images/buttonicon/icon_unlock_disabled.png");
private UISpinner mWidthSpinner;
private UISpinner mHeightSpinner;
private XCreator mCreator;
protected double width4Backup = 0;
protected double height4Backup = 0;
public AspectRatioLockedButton(UISpinner widthSpinner, UISpinner heightSpinner, XCreator creator) {
setUI(new BasicButtonUI());
setBorderPainted(false);
setBorder(null);
setContentAreaFilled(false);
setPreferredSize(new Dimension(24, 24));
this.mWidthSpinner = widthSpinner;
this.mHeightSpinner = heightSpinner;
this.mCreator = creator;
addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setSelected(!isSelected());
}
});
addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
mCreator.toData().setAspectRatioLocked(isLocked());
setToolTipText(isLockEnabled() ? null : i18nText("Fine-Design_Form_Widget_Lock_Aspect_Ratio_Button_ToolTip"));
if (isLocked() && isLockEnabled()) {
width4Backup = mWidthSpinner.getValue();
height4Backup = mHeightSpinner.getValue();
}
}
});
mWidthSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) {
mHeightSpinner.setValue(mWidthSpinner.getValue() * width4Backup / height4Backup, false);
}
}
});
mHeightSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (isLockEnabled() && isLocked() && width4Backup > 0 && height4Backup > 0) {
mWidthSpinner.setValue(mHeightSpinner.getValue() * height4Backup / width4Backup, false);
}
}
});
}
@Override
public Icon getIcon() {
if (this.isLocked()) {
if (this.isLockEnabled()) {
return enabledLocked;
} else {
return disabledLocked;
}
} else {
if (this.isLockEnabled()) {
return enabledUnLocked;
} else {
return disabledUnLocked;
}
}
}
public void setLocked(boolean locked) {
this.setSelected(locked);
}
public boolean isLocked() {
return this.isSelected();
}
public boolean isLockEnabled() {
return this.isEnabled();
}
public void setLockEnabled(boolean enabled) {
this.setEnabled(enabled);
}
public void populate(XCreator creator) {
Rectangle bounds = new Rectangle(creator.getBounds());
mCreator = creator;
width4Backup = bounds.width;
height4Backup = bounds.height;
Widget widget = creator.toData();
setLocked(widget.isAspectRatioLocked());
}
}
}

14
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java

@ -5,6 +5,7 @@ import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
@ -20,7 +21,7 @@ import java.awt.*;
* Created by kerry on 2017/8/29.
*/
public class BorderStyleWidgetDefinePane extends AbstractDataModify<AbstractBorderStyleWidget> {
private AccessibleWLayoutBorderStyleEditor borderStyleEditor;
private LayoutStylePane stylePane;
public BorderStyleWidgetDefinePane(XCreator xCreator) {
super(xCreator);
@ -29,13 +30,10 @@ public class BorderStyleWidgetDefinePane extends AbstractDataModify<AbstractBord
public void initComponent() {
borderStyleEditor = new AccessibleWLayoutBorderStyleEditor();
stylePane = new LayoutStylePane();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel advancePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), borderStyleEditor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
advancePane.add(jPanel, BorderLayout.CENTER);
advancePane.add(stylePane, BorderLayout.CENTER);
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane );
@ -50,14 +48,14 @@ public class BorderStyleWidgetDefinePane extends AbstractDataModify<AbstractBord
@Override
public void populateBean(AbstractBorderStyleWidget ob) {
borderStyleEditor.setValue(ob.getBorderStyle());
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
}
@Override
public AbstractBorderStyleWidget updateBean() {
AbstractBorderStyleWidget abstractBorderStyleWidget = (AbstractBorderStyleWidget)creator.toData();
abstractBorderStyleWidget.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
abstractBorderStyleWidget.setBorderStyle(stylePane.updateBean());
return abstractBorderStyleWidget;
}

91
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

@ -11,12 +11,12 @@ import com.fr.design.designer.properties.items.Item;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.WidgetBoundPane;
@ -38,7 +38,7 @@ import java.awt.Component;
public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
private static final int MAX_LABEL_WIDTH = 80;
private AccessibleWLayoutBorderStyleEditor borderStyleEditor;
private LayoutStylePane stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor;
private WidgetBoundPane boundPane;
@ -51,49 +51,66 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void initComponent() {
super.initComponent();
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
initUIComboBox();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
boundPane = new WidgetBoundPane(creator);
centerPane.add(boundPane, BorderLayout.CENTER);
borderStyleEditor = new AccessibleWLayoutBorderStyleEditor();
this.add(boundPane, BorderLayout.NORTH);
JPanel panel1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(panel1, BorderLayout.CENTER);
UIExpandablePane scalePane = new UIExpandablePane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Area_Scaling"),
280, 20,
createAreaScalePane()
);
panel1.add(scalePane, BorderLayout.NORTH);
UIExpandablePane advancedPane = new UIExpandablePane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"),
280, 20,
this.createAdvancePane());
panel1.add(advancedPane, BorderLayout.CENTER);
}
public JPanel createAdvancePane() {
JPanel advancedContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane = new LayoutStylePane();
advancedContentPane.add(stylePane, BorderLayout.NORTH);
watermarkEditor = new AccessibleBodyWatermarkEditor();
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
JPanel watermarkPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), borderStyleEditor},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
borderPane.add(jPanel, BorderLayout.CENTER);
UIExpandablePane advancedPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, borderPane);
centerPane.add(advancedPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.NORTH);
watermarkPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0));
advancedContentPane.add(watermarkPane, BorderLayout.CENTER);
return advancedContentPane;
}
public JPanel createThirdPane() {
public JPanel createAreaScalePane() {
initLayoutComboBox();
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p};
double[] colSize = {MAX_LABEL_WIDTH, f};
UILabel layoutTypeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type"));
JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{layoutTypeLabel, UIComponentUtils.wrapWithBorderLayoutPane(layoutCombox)}},
rowSize, colSize, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
UILabel scaleModeLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Scaling_Mode"));
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{scaleModeLabel, UIComponentUtils.wrapWithBorderLayoutPane(comboBox)}},
rowSize, colSize, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
jPanel.add(northPane, BorderLayout.NORTH);
jPanel.add(centerPane, BorderLayout.CENTER);
centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 0, 0));
return jPanel;
{layoutTypeLabel, layoutCombox},
{scaleModeLabel, comboBox}
},
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, IntervalConstants.INTERVAL_L1, 0));
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
containerPane.add(contentPane, BorderLayout.CENTER);
containerPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
return containerPane;
}
public void initLayoutComboBox() {
@ -113,7 +130,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void populateSubPane(WAbsoluteLayout ob) {
layoutCombox.setSelectedIndex(1);
borderStyleEditor.setValue(ob.getBorderStyle());
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
boundPane.populate();
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
}
@ -131,12 +148,12 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
if (layoutType == WBodyLayoutType.ABSOLUTE) {
((XWFitLayout) creator.getBackupParent()).toData().resetStyle();
if (state == WBodyLayoutType.FIT.getTypeValue()) {
XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent());
xwFitLayout.switch2FitBodyLayout(creator);
copyLayoutAttr(layout, xwFitLayout.toData());
XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent());
xwFitLayout.switch2FitBodyLayout(creator);
copyLayoutAttr(layout, xwFitLayout.toData());
}
}
layout.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
layout.setBorderStyle(stylePane.updateBean());
updateWatermark();
return layout;
}

93
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -16,6 +16,7 @@ import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
@ -23,7 +24,6 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.design.widget.ui.designer.component.PaddingBoundPane;
@ -37,12 +37,8 @@ import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.core.ReportUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import javax.swing.*;
import java.awt.*;
/**
* Created by ibm on 2017/8/2.
@ -55,7 +51,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
private UIComboBox adaptComboBox;
private UISpinner componentIntervel;
private PaddingBoundPane paddingBound;
private AccessibleWLayoutBorderStyleEditor stylePane;
private LayoutStylePane stylePane;
private AccessibleBodyWatermarkEditor watermarkEditor;
public FRFitLayoutDefinePane(XCreator xCreator) {
@ -68,31 +64,48 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
UIExpandablePane layoutExpandablePane = new UIExpandablePane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"),
280, 20,
createLayoutPane()
);
this.add(layoutExpandablePane, BorderLayout.NORTH);
JPanel advancePane = createAdvancePane();
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, advancePane);
this.add(advanceExpandablePane, BorderLayout.NORTH);
UIExpandablePane layoutExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, createLayoutPane());
this.add(layoutExpandablePane, BorderLayout.CENTER);
UIExpandablePane advanceExpandablePane = new UIExpandablePane(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"),
280, 20,
advancePane
);
this.add(advanceExpandablePane, BorderLayout.CENTER);
}
public JPanel createAdvancePane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane = new AccessibleWLayoutBorderStyleEditor();
JPanel contentPane0 = FRGUIPaneFactory.createBorderLayout_S_Pane();
stylePane = new LayoutStylePane();
contentPane0.add(stylePane, BorderLayout.NORTH);
JPanel contentPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentPane0.add(contentPane1, BorderLayout.CENTER);
watermarkEditor = new AccessibleBodyWatermarkEditor();
paddingBound = new PaddingBoundPane();
JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(
JPanel waterMarkPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), stylePane},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark")), watermarkEditor}
}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
jPanel.add(paddingBound, BorderLayout.CENTER);
jPanel.add(jp2, BorderLayout.NORTH);
return jPanel;
waterMarkPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
contentPane1.add(waterMarkPane, BorderLayout.NORTH);
paddingBound = new PaddingBoundPane();
contentPane1.add(paddingBound, BorderLayout.CENTER);
return contentPane0;
}
public JPanel createLayoutPane() {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel containerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
layoutComboBox = initUIComboBox(FRLayoutTypeItems.ITEMS);
adaptComboBox = initUIComboBox(FRFitConstraintsItems.ITEMS);
JPanel adaptComboBoxPane = UIComponentUtils.wrapWithBorderLayoutPane(adaptComboBox);
@ -102,27 +115,17 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
UILabel adaptLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Scale"));
UILabel intervalLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Component_Interval"));
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double adaptLabelColumnWidth = adaptLabel.getPreferredSize().width > ADAPT_LABEL_MAX_WIDTH ? ADAPT_LABEL_MAX_WIDTH : p;
double[] columnSize = {adaptLabelColumnWidth, f};
int[][] rowCount = {{1, 1}, {1, 1}};
JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
northPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, 0, 0, 0));
Component[][] components = new Component[][]{
new Component[]{adaptLabel, adaptComboBoxPane},
new Component[]{intervalLabel, componentIntervelPane}
};
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
centerPane.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L5, 0, 0));
jPanel.add(northPane, BorderLayout.NORTH);
jPanel.add(centerPane, BorderLayout.CENTER);
return jPanel;
JPanel contentPane = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout_Type")), layoutComboBox},
{adaptLabel, adaptComboBoxPane},
{intervalLabel, componentIntervelPane}
},
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
containerPane.add(contentPane, BorderLayout.CENTER);
return containerPane;
}
@ -154,7 +157,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
layoutComboBox.setSelectedIndex(ob.getBodyLayoutType().getTypeValue());
adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval());
stylePane.setValue(ob.getBorderStyle());
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
watermarkEditor.setValue(ReportUtils.getWatermarkAttrFromTemplate(getCurrentIOFile()));
}
@ -173,7 +176,7 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane<WFitLayout
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout_Padding_Duplicate"))) {
paddingBound.update(layout);
}
LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue();
LayoutBorderStyle borderStyle = stylePane.updateBean();
if (borderStyle != null) {
layout.setBorderStyle(borderStyle);
}

13
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java

@ -6,6 +6,8 @@ import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.xpane.CardTagLayoutStylePane;
import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleCardTagWLayoutBorderStyleEditor;
@ -26,7 +28,7 @@ import java.awt.event.ActionListener;
* Created by ibm on 2017/8/2.
*/
public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBorderLayout> {
private AccessibleCardTagWLayoutBorderStyleEditor accessibleCardTagWLayoutBorderStyleEditor;
private CardTagLayoutStylePane stylePane;
private UICheckBox setCarousel;
private UISpinner carouselInterval;
private JPanel IntervalPane;
@ -39,11 +41,8 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBorde
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
carouselInterval = new UISpinner(0, Integer.MAX_VALUE, 1, 0);
accessibleCardTagWLayoutBorderStyleEditor = new AccessibleCardTagWLayoutBorderStyleEditor();
stylePane = new CardTagLayoutStylePane();
JPanel accessibleCardlayout = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel stylePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style")), accessibleCardTagWLayoutBorderStyleEditor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
stylePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
accessibleCardlayout.add(stylePane, BorderLayout.CENTER);
UIExpandablePane advanceExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, accessibleCardlayout);
final JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -73,7 +72,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBorde
@Override
public void populateBean(WCardMainBorderLayout ob) {
WCardLayout cardLayout = ob.getCardPart();
accessibleCardTagWLayoutBorderStyleEditor.setValue(cardLayout.getBorderStyle());
stylePane.populateBean((LayoutBorderStyle) cardLayout.getBorderStyle());
setCarousel.setSelected(cardLayout.isCarousel());
IntervalPane.setVisible(cardLayout.isCarousel());
carouselInterval.setValue(cardLayout.getCarouselInterval());
@ -84,7 +83,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify<WCardMainBorde
public WCardMainBorderLayout updateBean() {
WCardMainBorderLayout layout = (WCardMainBorderLayout) creator.toData();
WCardLayout wCardLayout = layout.getCardPart();
wCardLayout.setBorderStyle((LayoutBorderStyle) accessibleCardTagWLayoutBorderStyleEditor.getValue());
wCardLayout.setBorderStyle(stylePane.updateBean());
wCardLayout.setCarousel(setCarousel.isSelected());
wCardLayout.setCarouselInterval(carouselInterval.getValue());
return layout;

36
designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java

@ -1,30 +1,23 @@
package com.fr.design.widget.ui.designer.layout;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.xpane.LayoutStylePane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.LayoutBorderStyle;
import com.fr.general.ComparatorUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.*;
import java.awt.*;
/**
* Created by ibm on 2017/8/3.
*/
public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget> extends AbstractDataModify<T> {
private AccessibleWLayoutBorderStyleEditor borderStyleEditor;
private LayoutStylePane stylePane;
public WTitleLayoutDefinePane(XCreator xCreator) {
super(xCreator);
@ -34,18 +27,8 @@ public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget
public void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel advancePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
borderStyleEditor = new AccessibleWLayoutBorderStyleEditor();
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}};
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Style")), borderStyleEditor}
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
advancePane.add(panel, BorderLayout.NORTH);
stylePane = new LayoutStylePane();
advancePane.add(stylePane, BorderLayout.NORTH);
JPanel centerPane = createCenterPane();
if(centerPane!=null){
advancePane.add(centerPane, BorderLayout.CENTER);
@ -69,15 +52,16 @@ public abstract class WTitleLayoutDefinePane<T extends AbstractBorderStyleWidget
@Override
public void populateBean(T ob) {
populateSubBean(ob);
borderStyleEditor.setValue(ob.getBorderStyle());
stylePane.populateBean((LayoutBorderStyle) ob.getBorderStyle());
}
@Override
public T updateBean() {
T e = updateSubBean();
if(!ComparatorUtils.equals(borderStyleEditor.getValue(), e.getBorderStyle())){
e.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
LayoutBorderStyle style = stylePane.updateBean();
if(!ComparatorUtils.equals(style, e.getBorderStyle())){
e.setBorderStyle(style);
}
return e;
}

4
designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java

@ -43,7 +43,7 @@ public class DesignerAppUtils {
private static final int DEFAULT_MAX_CACHE_SIZE = 50;
private static final int DEFAULT_CONCURRENCY_LEVEL = 8;
private static final long DEFAULT_EXPIRE_HOURS = 1;
private static boolean enablePluginTipDialog = true;
private volatile static boolean enablePluginTipDialog = true;
private static final Cache<String, Multimap<String, PluginMarkerAdapter>> ERROR_CACHE = CacheBuilder.newBuilder()
.maximumSize(DEFAULT_MAX_CACHE_SIZE)
@ -52,7 +52,7 @@ public class DesignerAppUtils {
.build();
public static void initPluginAllActiveListener() {
PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllActive, new PluginEventListener() {
PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllStop, new PluginEventListener() {
@Override
public void on(PluginEvent event) {
enablePluginTipDialog = false;

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

@ -76,6 +76,8 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
private int resolution = DesignerUIModeConfig.getInstance().getScreenResolution();
private int[] resizingBackupBounds = null;
protected GridMouseAdapter(Grid grid) {
this.grid = grid;
}
@ -339,6 +341,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
}
boolean isControlDown = InputEventBaseOnOS.isControlDown(evt);
boolean isShiftDown = evt.isShiftDown();
long systemCurrentTime = System.currentTimeMillis();
if (systemCurrentTime - lastMouseMoveTime <= DRAG_REFRESH_TIME) {// alex:Drag
@ -352,10 +355,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
return;
}
doWithMouseDragged(evt.getX(), evt.getY(), isControlDown);
doWithMouseDragged(evt.getX(), evt.getY(), isControlDown, isShiftDown);
}
private void doWithMouseDragged(int evtX, int evtY, boolean isControlDown) {
private void doWithMouseDragged(int evtX, int evtY, boolean isControlDown, boolean isShiftDown) {
ElementCasePane reportPane = grid.getElementCasePane();
if (reportPane.mustInVisibleRange()) {
@ -367,7 +370,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
Selection selection = reportPane.getSelection();
if (selection instanceof FloatSelection && !DesignerMode.isAuthorityEditing()) {
doWithFloatElementDragged(evtX, evtY, (FloatSelection) selection);
doWithFloatElementDragged(evtX, evtY, (FloatSelection) selection, isShiftDown);
grid.setDragType(GridUtils.DRAG_FLOAT);
} else if (grid.getDragType() == GridUtils.DRAG_CELLSELECTION_BOTTOMRIGHT_CORNER && !DesignerMode.isAuthorityEditing()) {
doWithCellElementDragged(evtX, evtY, (CellSelection) selection);
@ -392,36 +395,83 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
* @param fs
*/
private void doWithFloatElementDragged(int evtX, int evtY, FloatSelection fs) {
private void doWithFloatElementDragged(int evtX, int evtY, FloatSelection fs, boolean aspectRatio) {
ElementCase report = grid.getElementCasePane().getEditingElementCase();
// int resolution = ScreenResolution.getScreenResolution();
String floatName = fs.getSelectedFloatName();
FloatElement floatElement = report.getFloatElement(floatName);
int cursorType = grid.getCursor().getType();
int currentLeft = Math.min(oldEvtX, evtX);
int currentTop = Math.min(oldEvtY, evtY);
int currentRight = Math.max(oldEvtX, evtX);
int currentBottom = Math.max(oldEvtY, evtY);
int currentWidth = currentRight - currentLeft;
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 (aspectRatio) {
double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2);
double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2);
int newWidth = (int) (Math.sqrt((currentDiagonal / backupDiagonal) * (Math.pow(backupWidth, 2))));
int newHeight = (int) (Math.sqrt((currentDiagonal / backupDiagonal) * (Math.pow(backupHeight, 2))));
if (cursorType == Cursor.NW_RESIZE_CURSOR) {
currentLeft = currentRight - newWidth;
currentTop = currentBottom - newHeight;
} else if (cursorType == Cursor.NE_RESIZE_CURSOR) {
currentRight = currentLeft + newWidth;
currentTop = currentBottom - newHeight;
} else if (cursorType == Cursor.SW_RESIZE_CURSOR) {
currentLeft = currentRight - newWidth;
currentBottom = currentTop + newHeight;
} else if (cursorType == Cursor.SE_RESIZE_CURSOR){
currentRight = currentLeft + newWidth;
currentBottom = currentTop + newHeight;
}
}
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
FU floatX1_fu = FU.valueOfPix(Math.min(oldEvtX, evtX), resolution);
FU floatY1_fu = FU.valueOfPix(Math.min(oldEvtY, evtY), resolution);
FU floatX1_fu = FU.valueOfPix(currentLeft, resolution);
FU floatY1_fu = FU.valueOfPix(currentTop, resolution);
FU leftDistance = floatX1_fu.add(columnWidthList.getRangeValue(0, grid.getHorizontalValue()));
FU topDistance = floatY1_fu.add(rowHeightList.getRangeValue(0, grid.getVerticalValue()));
floatElement.setLeftDistance(leftDistance);
floatElement.setTopDistance(topDistance);
floatElement.setWidth(FU.valueOfPix(Math.max(oldEvtX, evtX), resolution).subtract(floatX1_fu));
floatElement.setHeight(FU.valueOfPix(Math.max(oldEvtY, evtY), resolution).subtract(floatY1_fu));
floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu));
floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu));
} else if (cursorType == Cursor.S_RESIZE_CURSOR || cursorType == Cursor.N_RESIZE_CURSOR) {
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
FU floatY1_fu = FU.valueOfPix(Math.min(oldEvtY, evtY), resolution);
FU floatY1_fu = FU.valueOfPix(currentTop, resolution);
FU topDistance = floatY1_fu.add(rowHeightList.getRangeValue(0, grid.getVerticalValue()));
floatElement.setTopDistance(topDistance);
floatElement.setHeight(FU.valueOfPix(Math.max(oldEvtY, evtY), resolution).subtract(floatY1_fu));
floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu));
if (aspectRatio) {
currentWidth = backupWidth * currentHeight / backupHeight;
currentRight = currentLeft + currentWidth;
FU floatX1_fu = FU.valueOfPix(currentLeft, resolution);
floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu));
}
} else if (cursorType == Cursor.W_RESIZE_CURSOR || cursorType == Cursor.E_RESIZE_CURSOR) {
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
FU floatX1_fu = FU.valueOfPix(Math.min(oldEvtX, evtX), resolution);
FU floatX1_fu = FU.valueOfPix(currentLeft, resolution);
FU leftDistance = floatX1_fu.add(columnWidthList.getRangeValue(0, grid.getHorizontalValue()));
floatElement.setLeftDistance(leftDistance);
floatElement.setWidth(FU.valueOfPix(Math.max(oldEvtX, evtX), resolution).subtract(floatX1_fu));
floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu));
if (aspectRatio) {
currentHeight = backupHeight * currentWidth / backupWidth;
currentBottom = currentTop + currentHeight;
FU floatY1_fu = FU.valueOfPix(currentTop, resolution);
floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu));
}
} else if (cursorType == Cursor.MOVE_CURSOR) {
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
@ -800,6 +850,13 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
} else if (cursorType == Cursor.E_RESIZE_CURSOR) {
setOld_X_AndOld_Y(floatArray[0], floatArray[1]);
}
if (Cursor.SW_RESIZE_CURSOR <= cursorType && cursorType <= Cursor.E_RESIZE_CURSOR) {
resizingBackupBounds = new int[] {
(int) floatArray[0], (int)floatArray[1],
(int) floatArray[2] - (int) floatArray[0], (int) floatArray[3] - (int) floatArray[1]
};
}
}
private void setOld_X_AndOld_Y(double x, double y) {

Loading…
Cancel
Save