Browse Source

Merge branch 'feature/10.0' of https://code.fineres.com/scm/~bjorn/design into feature/10.0

feature/10.0
白岳 4 years ago
parent
commit
1b0b51e746
  1. 30
      designer-base/src/main/java/com/fr/design/gui/frpane/UIPercentDragPane.java
  2. 55
      designer-base/src/main/java/com/fr/design/gui/icombobox/LineComboBox.java
  3. 10
      designer-base/src/main/java/com/fr/design/gui/style/BackgroundPane.java
  4. 4
      designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java
  5. 4
      designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java
  6. 23
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java
  7. 48
      designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java
  8. 5
      designer-base/src/main/java/com/fr/env/CheckServiceDialog.java
  9. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_border_image_help.png
  10. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_choose_inset.png
  11. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_delete_inset.png
  12. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_selected.png
  13. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_both_unselected.png
  14. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_selected.png
  15. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_left_unselected.png
  16. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_selected.png
  17. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_inset_right_unselected.png
  18. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_disabled.png
  19. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_lock_enabled.png
  20. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_disabled.png
  21. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/icon_unlock_enabled.png
  22. BIN
      designer-base/src/main/resources/com/fr/design/images/transparent_background.jpg
  23. 11
      designer-form/src/main/java/com/fr/design/designer/beans/location/AccessDirection.java
  24. 11
      designer-form/src/main/java/com/fr/design/designer/beans/location/Bottom.java
  25. 11
      designer-form/src/main/java/com/fr/design/designer/beans/location/Left.java
  26. 20
      designer-form/src/main/java/com/fr/design/designer/beans/location/LeftBottom.java
  27. 23
      designer-form/src/main/java/com/fr/design/designer/beans/location/LeftTop.java
  28. 13
      designer-form/src/main/java/com/fr/design/designer/beans/location/Right.java
  29. 18
      designer-form/src/main/java/com/fr/design/designer/beans/location/RightBottom.java
  30. 20
      designer-form/src/main/java/com/fr/design/designer/beans/location/RightTop.java
  31. 11
      designer-form/src/main/java/com/fr/design/designer/beans/location/Top.java
  32. 11
      designer-form/src/main/java/com/fr/design/designer/beans/models/StateModel.java
  33. 16
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java
  34. 14
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  35. 598
      designer-form/src/main/java/com/fr/design/gui/xpane/BorderLineAndImagePane.java
  36. 27
      designer-form/src/main/java/com/fr/design/gui/xpane/CardTagLayoutStylePane.java
  37. 502
      designer-form/src/main/java/com/fr/design/gui/xpane/LayoutStylePane.java
  38. 258
      designer-form/src/main/java/com/fr/design/gui/xpane/TitleInsetImagePane.java
  39. 7
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  40. 12
      designer-form/src/main/java/com/fr/design/mainframe/FormEditorKeyListener.java
  41. 13
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java
  42. 10
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java
  43. 6
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java
  44. 149
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  45. 14
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/BorderStyleWidgetDefinePane.java
  46. 91
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  47. 93
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  48. 13
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java
  49. 36
      designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/WTitleLayoutDefinePane.java
  50. 81
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

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

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

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

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

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

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

4
designer-base/src/main/java/com/fr/design/locale/impl/BbsRegisterMark.java

@ -16,8 +16,8 @@ import java.util.Map;
public class BbsRegisterMark implements LocaleMark<String> { public class BbsRegisterMark implements LocaleMark<String> {
private final Map<Locale, String> map = new HashMap<>(); private final Map<Locale, String> map = new HashMap<>();
private static final String BBS_REGISTER_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.register", "http://id.fanruan.com/register/register.php?clueSource=activityfr"); private static final String BBS_REGISTER_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.register", "https://id.fanruan.com/register/register.php?clueSource=activityfr");
private static final String BBS_REGISTER_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.register", "http://id.fanruan.com/register/register.php?clueSource=activityfr"); private static final String BBS_REGISTER_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.register", "https://id.fanruan.com/register/register.php?clueSource=activityfr");
private static final String BBS_REGISTER_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php"); private static final String BBS_REGISTER_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php");
private static final String BBS_REGISTER_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php"); private static final String BBS_REGISTER_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php");
private static final String BBS_REGISTER_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php"); private static final String BBS_REGISTER_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US", "https://id.fanruan.com/en/register/register.php");

4
designer-base/src/main/java/com/fr/design/locale/impl/BbsResetMark.java

@ -16,8 +16,8 @@ import java.util.Map;
public class BbsResetMark implements LocaleMark<String> { public class BbsResetMark implements LocaleMark<String> {
private final Map<Locale, String> map = new HashMap<>(); private final Map<Locale, String> map = new HashMap<>();
private static final String BBS_RESET_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.reset", "http://id.fanruan.com/forget/forget.php?clue=activityfr"); private static final String BBS_RESET_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.reset", "https://id.fanruan.com/forget/forget.php?clue=activityfr");
private static final String BBS_RESET_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.reset", "http://id.fanruan.com/forget/forget.php?clue=activityfr"); private static final String BBS_RESET_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.reset", "https://id.fanruan.com/forget/forget.php?clue=activityfr");
private static final String BBS_RESET_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php"); private static final String BBS_RESET_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php");
private static final String BBS_RESET_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php"); private static final String BBS_RESET_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php");
private static final String BBS_RESET_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php"); private static final String BBS_RESET_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US", "https://id.fanruan.com/en/forget/forget.php");

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

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

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

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

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

@ -167,8 +167,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
centerPanel.add(detailsPane, BorderLayout.CENTER); centerPanel.add(detailsPane, BorderLayout.CENTER);
JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_M_Pane(); JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_M_Pane();
buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
boolean Sync = false; if (isOnline()) {
if (Sync && isOnline()) {
ignoreButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_Ignore")); ignoreButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_Ignore"));
ignoreButton.addActionListener(this); ignoreButton.addActionListener(this);
syncButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_To_Local")); syncButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Sync_To_Local"));
@ -184,6 +183,8 @@ public class CheckServiceDialog extends JDialog implements ActionListener {
buttonPanel.add(progressBar, BorderLayout.CENTER); buttonPanel.add(progressBar, BorderLayout.CENTER);
buttonPanel.add(syncButton, BorderLayout.EAST); buttonPanel.add(syncButton, BorderLayout.EAST);
} else { } else {
UILabel adviceLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Sync_Suggestion"));
centerPanel.add(adviceLabel, BorderLayout.SOUTH);
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm")); UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm"));
okButton.addActionListener(this); okButton.addActionListener(this);
buttonPanel.add(okButton, BorderLayout.EAST); buttonPanel.add(okButton, BorderLayout.EAST);

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

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

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

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

@ -15,6 +15,12 @@ public class Bottom extends AccessDirection {
Rectangle oldbounds) { Rectangle oldbounds) {
current_bounds.height = sorption(0, oldbounds.height + dy + oldbounds.y, current_bounds, designer)[1] current_bounds.height = sorption(0, oldbounds.height + dy + oldbounds.y, current_bounds, designer)[1]
- oldbounds.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; return current_bounds;
} }
@ -23,6 +29,11 @@ public class Bottom extends AccessDirection {
return Cursor.S_RESIZE_CURSOR; 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 @Override
public int getActual() { public int getActual() {
return Direction.BOTTOM; return Direction.BOTTOM;

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

@ -15,6 +15,12 @@ public class Left extends AccessDirection {
Rectangle oldbounds) { Rectangle oldbounds) {
current_bounds.x = sorption(oldbounds.x + dx, 0, current_bounds, designer)[0]; current_bounds.x = sorption(oldbounds.x + dx, 0, current_bounds, designer)[0];
current_bounds.width = oldbounds.width - current_bounds.x + oldbounds.x; 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; return current_bounds;
} }
@ -23,6 +29,11 @@ public class Left extends AccessDirection {
return Cursor.W_RESIZE_CURSOR; 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 @Override
public int getActual() { public int getActual() {
return Direction.LEFT; return Direction.LEFT;

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

@ -17,6 +17,21 @@ public class LeftBottom extends AccessDirection {
current_bounds.x = xy[0]; current_bounds.x = xy[0];
current_bounds.width = oldbounds.width - current_bounds.x + oldbounds.x; current_bounds.width = oldbounds.width - current_bounds.x + oldbounds.x;
current_bounds.height = xy[1] - oldbounds.y; 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; return current_bounds;
} }
@ -25,6 +40,11 @@ public class LeftBottom extends AccessDirection {
return Cursor.SW_RESIZE_CURSOR; 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 @Override
public int getActual() { public int getActual() {
return Direction.LEFT_BOTTOM; return Direction.LEFT_BOTTOM;

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

@ -6,6 +6,7 @@ import java.awt.Rectangle;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
public class LeftTop extends AccessDirection { public class LeftTop extends AccessDirection {
public LeftTop() { public LeftTop() {
} }
@ -17,6 +18,23 @@ public class LeftTop extends AccessDirection {
current_bounds.y = xy[1]; current_bounds.y = xy[1];
current_bounds.width = oldbounds.width - current_bounds.x + oldbounds.x; current_bounds.width = oldbounds.width - current_bounds.x + oldbounds.x;
current_bounds.height = oldbounds.height - current_bounds.y + oldbounds.y; 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; return current_bounds;
} }
@ -25,6 +43,11 @@ public class LeftTop extends AccessDirection {
return Cursor.NW_RESIZE_CURSOR; 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 @Override
public int getActual() { public int getActual() {
return Direction.LEFT_TOP; return Direction.LEFT_TOP;

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

@ -3,7 +3,9 @@ package com.fr.design.designer.beans.location;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Rectangle; import java.awt.Rectangle;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget;
public class Right extends AccessDirection { public class Right extends AccessDirection {
@ -15,6 +17,12 @@ public class Right extends AccessDirection {
Rectangle oldbounds) { Rectangle oldbounds) {
current_bounds.width = sorption(oldbounds.x + dx + oldbounds.width, 0, current_bounds, designer)[0] current_bounds.width = sorption(oldbounds.x + dx + oldbounds.width, 0, current_bounds, designer)[0]
- oldbounds.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; return current_bounds;
} }
@ -23,6 +31,11 @@ public class Right extends AccessDirection {
return Cursor.E_RESIZE_CURSOR; 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 @Override
public int getActual() { public int getActual() {
return Direction.RIGHT; return Direction.RIGHT;

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

@ -16,6 +16,19 @@ public class RightBottom extends AccessDirection {
int[] xy = sorption(oldbounds.x + dx + oldbounds.width, oldbounds.height + dy + oldbounds.y, current_bounds, designer); 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.width = xy[0] - oldbounds.x;
current_bounds.height = xy[1] - oldbounds.y; 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; return current_bounds;
} }
@ -24,6 +37,11 @@ public class RightBottom extends AccessDirection {
return Cursor.SE_RESIZE_CURSOR; 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 @Override
public int getActual() { public int getActual() {
return Direction.RIGHT_BOTTOM; return Direction.RIGHT_BOTTOM;

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

@ -16,6 +16,21 @@ public class RightTop extends AccessDirection {
current_bounds.y = xy[1]; current_bounds.y = xy[1];
current_bounds.height = oldbounds.height - current_bounds.y + oldbounds.y; current_bounds.height = oldbounds.height - current_bounds.y + oldbounds.y;
current_bounds.width = xy[0] - oldbounds.x; 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; return current_bounds;
} }
@ -24,6 +39,11 @@ public class RightTop extends AccessDirection {
return Cursor.NE_RESIZE_CURSOR; 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 @Override
public int getActual() { public int getActual() {
return Direction.RIGHT_TOP; return Direction.RIGHT_TOP;

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

@ -15,6 +15,12 @@ public class Top extends AccessDirection {
Rectangle oldbounds) { Rectangle oldbounds) {
current_bounds.y = sorption(0, dy + oldbounds.y, current_bounds, designer)[1]; current_bounds.y = sorption(0, dy + oldbounds.y, current_bounds, designer)[1];
current_bounds.height = oldbounds.height - current_bounds.y + oldbounds.y; 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; return current_bounds;
} }
@ -23,6 +29,11 @@ public class Top extends AccessDirection {
return Cursor.N_RESIZE_CURSOR; 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 @Override
public int getActual() { public int getActual() {
return Direction.TOP; return Direction.TOP;

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

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

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

@ -48,7 +48,15 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
return (AbstractBorderStyleWidget) data; 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(); BorderPacker style = toData().getBorderStyle();
initBorderStyle(); initBorderStyle();
if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) {
@ -121,6 +129,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
title.setFont(wTitle.getFrFont()); title.setFont(wTitle.getFrFont());
title.setTextalign(wTitle.getPosition()); title.setTextalign(wTitle.getPosition());
title.setBackground(wTitle.getBackground()); 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){ private WidgetValue getTitleValue(TitlePacker wTitle){

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

@ -5,6 +5,7 @@ package com.fr.design.designer.creator;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.background.ImageBackground;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.form.util.FontTransformUtil; import com.fr.design.form.util.FontTransformUtil;
import com.fr.design.form.util.XCreatorConstants; 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.Label;
import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Background;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -94,10 +96,18 @@ public class XLabel extends XWidgetCreator {
} }
if (label.getWidgetValue() != null) { if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create(); 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) .deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP)
.deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE), .deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE),
insetImage, label.getInsetImagePadding(), label.isInsetRelativeTextLeft(), label.isInsetRelativeTextRight(),
FontTransformUtil.getDesignerFontResolution()); FontTransformUtil.getDesignerFontResolution());
} }

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

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

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

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

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

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

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

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

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

@ -475,7 +475,12 @@ public class EditingMouseListener extends MouseInputAdapter {
if (DesignerMode.isAuthorityEditing()) { if (DesignerMode.isAuthorityEditing()) {
return; 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); stateModel.startSelecting(e);
} }
// 如果当前是左键拖拽状态,拖拽组件 // 如果当前是左键拖拽状态,拖拽组件

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

@ -27,7 +27,11 @@ public class FormEditorKeyListener extends KeyAdapter{
@Override @Override
public void keyPressed(KeyEvent e) { 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); designer.setCursor(ADDCURSOR);
} }
int code = e.getKeyCode(); int code = e.getKeyCode();
@ -57,7 +61,11 @@ public class FormEditorKeyListener extends KeyAdapter{
} }
public void keyReleased(KeyEvent e) { 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)); designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} }
if (moved) { if (moved) {

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

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.AdapterBus;
import com.fr.design.designer.beans.LayoutAdapter; 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.beans.location.Direction;
import com.fr.design.designer.creator.XComponent; import com.fr.design.designer.creator.XComponent;
import com.fr.design.designer.creator.XCreator; 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 重置报表块缩略图 * @Description 重置报表块缩略图
* @param: creator * @param: creator

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

@ -67,10 +67,6 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele
this.designer = designer; this.designer = designer;
initComponents(); initComponents();
initDefinePane(); initDefinePane();
widgetBoundPane = createWidgetBoundPane(xCreator);
if (widgetBoundPane != null) {
attriCardPane.add(widgetBoundPane, BorderLayout.CENTER);
}
} }
public XLayoutContainer getParent(XCreator source) { public XLayoutContainer getParent(XCreator source) {
@ -162,6 +158,10 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele
jPanel.add(uiExpandablePane, BorderLayout.NORTH); jPanel.add(uiExpandablePane, BorderLayout.NORTH);
widgetBoundPane = createWidgetBoundPane(xCreator);
if (widgetBoundPane != null) {
attriCardPane.add(widgetBoundPane, BorderLayout.NORTH);
}
} }
private static void freshPropertyMode(XCreator xCreator) { private static void freshPropertyMode(XCreator xCreator) {
@ -187,7 +187,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane implements Rele
JComponent jComponent = definePane.toSwingComponent(); JComponent jComponent = definePane.toSwingComponent();
attriCardPane.add(jComponent, BorderLayout.NORTH); attriCardPane.add(jComponent, BorderLayout.CENTER);
currentEditorDefinePane = definePane; currentEditorDefinePane = definePane;
} }

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

@ -9,8 +9,7 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.design.widget.WidgetBoundsPaneFactory; import com.fr.design.widget.WidgetBoundsPaneFactory;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import java.awt.*;
import java.awt.Rectangle;
/** /**
@ -30,11 +29,12 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane {
y = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d); y = new UIBoundSpinner(0, Integer.MAX_VALUE, 1, 0d);
width = 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); 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")); 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")); 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")); 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")); 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 @Override

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -75,6 +75,8 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
private int resolution = ScreenResolution.getScreenResolution(); private int resolution = ScreenResolution.getScreenResolution();
private int[] resizingBackupBounds = null;
protected GridMouseAdapter(Grid grid) { protected GridMouseAdapter(Grid grid) {
this.grid = grid; this.grid = grid;
} }
@ -338,6 +340,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
} }
boolean isControlDown = InputEventBaseOnOS.isControlDown(evt); boolean isControlDown = InputEventBaseOnOS.isControlDown(evt);
boolean isShiftDown = evt.isShiftDown();
long systemCurrentTime = System.currentTimeMillis(); long systemCurrentTime = System.currentTimeMillis();
if (systemCurrentTime - lastMouseMoveTime <= DRAG_REFRESH_TIME) {// alex:Drag if (systemCurrentTime - lastMouseMoveTime <= DRAG_REFRESH_TIME) {// alex:Drag
@ -351,10 +354,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
return; 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(); ElementCasePane reportPane = grid.getElementCasePane();
if (reportPane.mustInVisibleRange()) { if (reportPane.mustInVisibleRange()) {
@ -366,7 +369,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
Selection selection = reportPane.getSelection(); Selection selection = reportPane.getSelection();
if (selection instanceof FloatSelection && !DesignerMode.isAuthorityEditing()) { if (selection instanceof FloatSelection && !DesignerMode.isAuthorityEditing()) {
doWithFloatElementDragged(evtX, evtY, (FloatSelection) selection); doWithFloatElementDragged(evtX, evtY, (FloatSelection) selection, isShiftDown);
grid.setDragType(GridUtils.DRAG_FLOAT); grid.setDragType(GridUtils.DRAG_FLOAT);
} else if (grid.getDragType() == GridUtils.DRAG_CELLSELECTION_BOTTOMRIGHT_CORNER && !DesignerMode.isAuthorityEditing()) { } else if (grid.getDragType() == GridUtils.DRAG_CELLSELECTION_BOTTOMRIGHT_CORNER && !DesignerMode.isAuthorityEditing()) {
doWithCellElementDragged(evtX, evtY, (CellSelection) selection); doWithCellElementDragged(evtX, evtY, (CellSelection) selection);
@ -391,36 +394,83 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
* @param fs * @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(); ElementCase report = grid.getElementCasePane().getEditingElementCase();
// int resolution = ScreenResolution.getScreenResolution(); // int resolution = ScreenResolution.getScreenResolution();
String floatName = fs.getSelectedFloatName(); String floatName = fs.getSelectedFloatName();
FloatElement floatElement = report.getFloatElement(floatName); FloatElement floatElement = report.getFloatElement(floatName);
int cursorType = grid.getCursor().getType(); 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 (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 columnWidthList = ReportHelper.getColumnWidthList(report);
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(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 leftDistance = floatX1_fu.add(columnWidthList.getRangeValue(0, grid.getHorizontalValue()));
FU topDistance = floatY1_fu.add(rowHeightList.getRangeValue(0, grid.getVerticalValue())); FU topDistance = floatY1_fu.add(rowHeightList.getRangeValue(0, grid.getVerticalValue()));
floatElement.setLeftDistance(leftDistance); floatElement.setLeftDistance(leftDistance);
floatElement.setTopDistance(topDistance); floatElement.setTopDistance(topDistance);
floatElement.setWidth(FU.valueOfPix(Math.max(oldEvtX, evtX), resolution).subtract(floatX1_fu)); floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu));
floatElement.setHeight(FU.valueOfPix(Math.max(oldEvtY, evtY), resolution).subtract(floatY1_fu)); floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu));
} else if (cursorType == Cursor.S_RESIZE_CURSOR || cursorType == Cursor.N_RESIZE_CURSOR) { } else if (cursorType == Cursor.S_RESIZE_CURSOR || cursorType == Cursor.N_RESIZE_CURSOR) {
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); 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())); FU topDistance = floatY1_fu.add(rowHeightList.getRangeValue(0, grid.getVerticalValue()));
floatElement.setTopDistance(topDistance); 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) { } else if (cursorType == Cursor.W_RESIZE_CURSOR || cursorType == Cursor.E_RESIZE_CURSOR) {
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); 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())); FU leftDistance = floatX1_fu.add(columnWidthList.getRangeValue(0, grid.getHorizontalValue()));
floatElement.setLeftDistance(leftDistance); 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) { } else if (cursorType == Cursor.MOVE_CURSOR) {
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report);
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report);
@ -799,6 +849,13 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
} else if (cursorType == Cursor.E_RESIZE_CURSOR) { } else if (cursorType == Cursor.E_RESIZE_CURSOR) {
setOld_X_AndOld_Y(floatArray[0], floatArray[1]); 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) { private void setOld_X_AndOld_Y(double x, double y) {

Loading…
Cancel
Save