diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java index 01af97293..58a021812 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java +++ b/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 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"); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index f3a97ffb1..e55aaa2dd 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/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 0) { diff --git a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java b/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java index 8adebba4f..92e417146 100644 --- a/designer-base/src/main/java/com/fr/design/login/guide/DesignerGuideHelper.java +++ b/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()) { diff --git a/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java b/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java index c053fc0e5..f3768629b 100644 --- a/designer-base/src/main/java/com/fr/design/login/message/DesignerMessageHelper.java +++ b/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() { diff --git a/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java b/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java index 26e095df6..a39a0be4b 100644 --- a/designer-base/src/main/java/com/fr/design/login/utils/DesignerLoginUtils.java +++ b/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(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java index 24b3ebfc4..10629de02 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java +++ b/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(); diff --git a/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java b/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java index 9b6e7b5c8..ae3dfc255 100644 --- a/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java +++ b/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); } diff --git a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java index 185268e79..fb1adae6f 100644 --- a/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -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); diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png new file mode 100644 index 000000000..89a12190b Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_choose_inset.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_choose_inset.png new file mode 100644 index 000000000..18b39efd1 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_choose_inset.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_delete_inset.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_delete_inset.png new file mode 100644 index 000000000..3730383ee Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_delete_inset.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png new file mode 100644 index 000000000..018fa1257 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png new file mode 100644 index 000000000..3a822ba8b Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png new file mode 100644 index 000000000..b34a28704 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png new file mode 100644 index 000000000..7e8696b97 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_selected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_selected.png new file mode 100644 index 000000000..d50ee4a07 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_selected.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_unselected.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_unselected.png new file mode 100644 index 000000000..d62026a7a Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_unselected.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png new file mode 100644 index 000000000..b498e7c14 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_enabled.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_enabled.png new file mode 100644 index 000000000..38301e14d Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_enabled.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png new file mode 100644 index 000000000..6785a5130 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_enabled.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_enabled.png new file mode 100644 index 000000000..5d2582d80 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_enabled.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg b/designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg new file mode 100644 index 000000000..b04da96ea Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg differ diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index d1ac6aa14..4a0e7adc5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -209,9 +209,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } 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 { } } }; - 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 { 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")); } } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java index 3538d2fd9..be44eae81 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java +++ b/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,8 +195,17 @@ 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 diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/Bottom.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/Bottom.java index 1cbfe1c41..0f51f3c88 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/Bottom.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/Left.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/Left.java index d78b08c03..3e773bf0e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/Left.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/LeftBottom.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/LeftBottom.java index 3c1a37241..a60b16585 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/LeftBottom.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/LeftTop.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/LeftTop.java index 7687f6136..159b317eb 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/LeftTop.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/Right.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/Right.java index aa44a8fb3..deab920a2 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/Right.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/RightBottom.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/RightBottom.java index 6247ce3a1..99a013fe3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/RightBottom.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/RightTop.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/RightTop.java index 3434e5d10..d858fc080 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/RightTop.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/location/Top.java b/designer-form/src/main/java/com/fr/design/designer/beans/location/Top.java index 7f20213f2..5817e4541 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/location/Top.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java index 85a328032..34b03bc52 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java +++ b/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()); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index e4b5377ba..e174c122f 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -47,8 +47,16 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ public AbstractBorderStyleWidget toData() { 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){ diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java index df2252c7a..154091a29 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java +++ b/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()); } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java new file mode 100644 index 000000000..67eb8c1ae --- /dev/null +++ b/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) { + + } + } +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java new file mode 100644 index 000000000..5e6f7c06c --- /dev/null +++ b/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() { } +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java new file mode 100644 index 000000000..265de1aba --- /dev/null +++ b/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 { + 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( + 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); + } + } +} diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java new file mode 100644 index 000000000..1a207a0b3 --- /dev/null +++ b/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 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(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; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 405251ea6..484319eaa 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -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); } // 如果当前是左键拖拽状态,拖拽组件 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormEditorKeyListener.java b/designer-form/src/main/java/com/fr/design/mainframe/FormEditorKeyListener.java index 81f3d6efc..13209710f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormEditorKeyListener.java +++ b/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) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java index d1d0a2f83..956e1cb66 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java +++ b/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 diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 609e45b5d..0de710415 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/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; diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java index 5604ef4be..30c90b326 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java +++ b/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 diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java index ab148f2ae..5e1c8dee7 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java +++ b/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()); + } + } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java index dbe2735e3..fe6634b1f 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java +++ b/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 { - private AccessibleWLayoutBorderStyleEditor borderStyleEditor; + private LayoutStylePane stylePane; public BorderStyleWidgetDefinePane(XCreator xCreator) { super(xCreator); @@ -29,13 +30,10 @@ public class BorderStyleWidgetDefinePane extends AbstractDataModify 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 { - private AccessibleCardTagWLayoutBorderStyleEditor accessibleCardTagWLayoutBorderStyleEditor; + private CardTagLayoutStylePane stylePane; private UICheckBox setCarousel; private UISpinner carouselInterval; private JPanel IntervalPane; @@ -39,11 +41,8 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify extends AbstractDataModify { - private AccessibleWLayoutBorderStyleEditor borderStyleEditor; + private LayoutStylePane stylePane; public WTitleLayoutDefinePane(XCreator xCreator) { super(xCreator); @@ -34,18 +27,8 @@ public abstract class WTitleLayoutDefinePane> 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; diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index 060bc2ace..580c97f6f 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/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) {