Browse Source

Pull request #1934: REPORT-31758 决策报表设计面板允许进行缩放

Merge in DESIGN/design from ~KERRY/design_10.0:release/10.0 to release/10.0

* commit 'b0f6f123f3ddfa9ab6979243be7ad93b6c3c6e70':
  代码修改
  添加快捷键
  问题修改
  添加单元测试
  代码修改
  REPORT-31758  决策报表设计面板允许进行缩放
feature/big-screen
kerry 4 years ago
parent
commit
188ee0dd85
  1. 351
      designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java
  2. 51
      designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java
  3. 15
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java
  4. 23
      designer-form/src/main/java/com/fr/design/designer/creator/XButton.java
  5. 9
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  6. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  7. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java
  8. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XTextEditor.java
  9. 16
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  10. 56
      designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java
  11. 86
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  12. 6
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  13. 2
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  14. 83
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  15. 189
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java
  16. 6
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  17. 9
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java
  18. 17
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java
  19. 32
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  20. 24
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java

351
designer-base/src/main/java/com/fr/design/mainframe/JFormSliderPane.java

@ -1,45 +1,27 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ibutton.UISliderButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.islider.UISlider;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.NumberFormatter;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
@ -51,72 +33,37 @@ public class JFormSliderPane extends JPanel {
private static final double ONEPOINTEIGHT = 1.8;
private static final int SIX = 6;
private static final int TEN = 10;
private static final int ONE_EIGHT = 18;
private static final int FONT_SIZE = 12;
private static final int SPINNER_WIDTH = 45;
private static final int SPINNER_HEIGHT = 20;
private static final int HALF_HUNDRED = 50;
private static final int HUNDRED = 100;
private static final int TWO_HUNDRED = 200;
private static final int THREE_HUNDRED = 300;
private static final int FOUR_HUNDRED = 400;
private static final int DIALOG_WIDTH = 157;
private static final int DIALOG_HEIGHT = 172;
private static final int SLIDER_WIDTH = 220;
private static final int SLIDER_HEIGHT = 20;
private static final int SHOWVALBUTTON_WIDTH = 40;
private static final int SHOWVALBUTTON_HEIGHTH = 20;
private static final int SLIDER_GAP = 5;
private static final String SUFFIX = "%";
private static final String REGEX = "[\\d%]*";
private static final int TOOLTIP_Y = 30;
private static final Color BACK_COLOR = new Color(245, 245, 247);
public int showValue = 100;
public double resolutionTimes = 1.0;
private UITextField showVal;
private JSpinner showValSpinner;
private UITextField showValField;
private UISlider slider;
private int times;
private int sliderValue;
private UIButton downButton;
private UIButton upButton;
private UISliderButton showValButton;
private UIRadioButton twoHundredButton;
private UIRadioButton oneHundredButton;
private UIRadioButton sevenFiveButton;
private UIRadioButton fiveTenButton;
private UIRadioButton twoFiveButton;
private UIRadioButton selfAdaptButton;
private UIRadioButton customButton;
//拖动条处理和button、直接输入不一样
private boolean isButtonOrIsTxt = true;
//是否选中指定的几个缩放等级,避免触发不必要的事件
private boolean selectSpecified = false;
private FormPopupPane dialog;
private int upButtonX;
private JPanel dialogContentPanel;
public JFormSliderPane() {
this.setLayout(new BorderLayout());
initSlider();
initShowValSpinner();
//MoMeak:控制只能输入10-400
JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0");
showValSpinner.setEditor(editor);
JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField();
textField.setEditable(true);
DefaultFormatterFactory factory = (DefaultFormatterFactory) textField.getFormatterFactory();
NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter();
formatter.setAllowsInvalid(false);
initDownUpButton();
initShowValButton();
initUIRadioButton();
initPane();
initShowValField();
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
panel.add(downButton);
panel.add(slider);
panel.add(upButton);
panel.add(showValButton);
panel.add(showValField);
panel.setBackground(BACK_COLOR);
this.add(panel, BorderLayout.NORTH);
}
@ -131,6 +78,7 @@ public class JFormSliderPane extends JPanel {
return new Point(event.getX(), event.getY() - TOOLTIP_Y);
}
};
slider.setValue(HALF_HUNDRED);
slider.setUI(new JSliderPaneUI(slider));
slider.addChangeListener(listener);
slider.setPreferredSize(new Dimension(220, 20));
@ -139,16 +87,6 @@ public class JFormSliderPane extends JPanel {
slider.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Slider"));
}
private void initShowValSpinner() {
showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, 0, FOUR_HUNDRED, 1)) {
public Point getToolTipLocation(MouseEvent event) {
return new Point(event.getX(), event.getY() - TOOLTIP_Y);
}
};
showValSpinner.setEnabled(true);
showValSpinner.addChangeListener(showValSpinnerChangeListener);
showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT));
}
private void initDownUpButton() {
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/normalDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png"), BaseUtils.readIcon("com/fr/design/images/data/source/hoverDown20.png")) {
@ -173,128 +111,76 @@ public class JFormSliderPane extends JPanel {
upButton.addActionListener(buttonActionListener);
}
private void initShowValButton() {
showValButton = new UISliderButton(showValSpinner.getValue() + "%");
showValButton.setBackground(BACK_COLOR);
showValButton.setBorderPainted(false);
showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH));
showValButton.addActionListener(showValButtonActionListener);
showValButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Grade"));
}
private void initShowValField() {
showValField = new UITextField(showValue + SUFFIX);
showValField.setBorderPainted(false);
showValField.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH));
showValField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent evt) {
int code = evt.getKeyCode();
private void initUIRadioButton() {
twoHundredButton = new UIRadioButton("200%");
oneHundredButton = new UIRadioButton("100%");
sevenFiveButton = new UIRadioButton("75%");
fiveTenButton = new UIRadioButton("50%");
twoFiveButton = new UIRadioButton("25%");
selfAdaptButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Self_Adapt_Button"));
selfAdaptButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE));
customButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_Custom_Button"));
customButton.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE));
twoHundredButton.addItemListener(radioButtonItemListener);
oneHundredButton.addItemListener(radioButtonItemListener);
sevenFiveButton.addItemListener(radioButtonItemListener);
fiveTenButton.addItemListener(radioButtonItemListener);
twoFiveButton.addItemListener(radioButtonItemListener);
customButton.addItemListener(new ItemListener() {
if (code == KeyEvent.VK_ENTER) {
showValue = parseInputValue(showValField.getText());
showValField.setText(showValue + SUFFIX);
showValFieldChange();
}
}
});
showValField.setDocument(new PlainDocument() {
@Override
public void itemStateChanged(ItemEvent e) {
JRadioButton temp = (JRadioButton) e.getSource();
if (temp.isSelected()) {
JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField();
textField.requestFocus();
textField.selectAll();
public void insertString(int offset, String s, AttributeSet a) throws BadLocationException {
if (!s.matches(REGEX)) {
return;
}
super.insertString(offset, s, a);
}
});
ButtonGroup bg = new ButtonGroup();// 初始化按钮组
bg.add(twoHundredButton);// 加入按钮组
bg.add(oneHundredButton);
bg.add(sevenFiveButton);
bg.add(fiveTenButton);
bg.add(twoFiveButton);
bg.add(selfAdaptButton);
bg.add(customButton);
customButton.setSelected(true);
}
private void initPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p, p, p, p, p, p, p};
UILabel upLabel = new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Scale_EnlargeOrReduce"));
upLabel.setOpaque(false);
JPanel septPane = new JPanel(new BorderLayout());
JSeparator sept = new JSeparator();
sept.setBackground(new Color(232, 232, 233));
septPane.add(sept, BorderLayout.NORTH);
septPane.setBorder(BorderFactory.createEmptyBorder(2, 5, 1, 10));
septPane.setBackground(BACK_COLOR);
twoHundredButton.setBackground(BACK_COLOR);
oneHundredButton.setBackground(BACK_COLOR);
sevenFiveButton.setBackground(BACK_COLOR);
fiveTenButton.setBackground(BACK_COLOR);
twoFiveButton.setBackground(BACK_COLOR);
// selfAdaptButton.setBackground(BACK_COLOR);
customButton.setBackground(BACK_COLOR);
Component[][] components = new Component[][]{
new Component[]{upLabel, null},
new Component[]{septPane, null},
new Component[]{twoHundredButton, null},
new Component[]{oneHundredButton, null},
new Component[]{sevenFiveButton, null},
new Component[]{fiveTenButton, null},
new Component[]{twoFiveButton, null},
new Component[]{customButton, createSpinnerPanel()}
};
dialogContentPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_MEDIUM, 0);
dialogContentPanel.setBackground(BACK_COLOR);
dialogContentPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
private void showValFieldChange() {
isButtonOrIsTxt = true;
showValue = getPreferredValue(showValue);
refreshShowValueFieldText();
refreshSlider();
}
private JPanel createSpinnerPanel() {
JPanel spinnerPanel = new JPanel(new FlowLayout());
spinnerPanel.add(showValSpinner);
UILabel percent = new UILabel("%");
percent.setFont(new Font("SimSun", Font.PLAIN, FONT_SIZE));
spinnerPanel.add(percent);
spinnerPanel.setBackground(BACK_COLOR);
return spinnerPanel;
private int getPreferredValue(int value){
if (value > FOUR_HUNDRED) {
value = FOUR_HUNDRED;
}
if (value < TEN) {
value = TEN;
}
return value;
}
private ActionListener showValButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
popupDialog();
}
};
private void refreshShowValueFieldText(){
showValField.setText(showValue + SUFFIX);
}
private ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int val = (int) ((UIBasicSpinner) e.getSource()).getValue();
isButtonOrIsTxt = true;
resolutionTimes = divide(showValue, 100, 2);
if (val > FOUR_HUNDRED) {
showValSpinner.setValue(FOUR_HUNDRED);
val = FOUR_HUNDRED;
}
if (val < TEN) {
showValSpinner.setValue(TEN);
val = TEN;
}
refreshSlider(val);
refreshBottun(val);
JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField();
textField.setCaretPosition(showValSpinner.getValue().toString().length());
if (!selectSpecified) {
customButton.setSelected(true);
}
private int parseInputValue(String text){
if (text.endsWith(SUFFIX)){
text = text.substring(0, text.length() -1);
}
};
try{
return Integer.parseInt(text);
}catch (NumberFormatException e){
return HUNDRED;
}
}
//定义一个监听器,用于监听所有滑动条
@ -302,13 +188,12 @@ public class JFormSliderPane extends JPanel {
public void stateChanged(ChangeEvent event) {
//取出滑动条的值,并在文本中显示出来
if (!isButtonOrIsTxt) {
customButton.setSelected(true);
EventQueue.invokeLater(new Runnable() {
public void run() {
sliderValue = slider.getValue();
getTimes(sliderValue);
showValue = times;
showValSpinner.setValue(times);
refreshShowValueFieldText();
}
});
} else {
@ -317,41 +202,23 @@ public class JFormSliderPane extends JPanel {
}
};
private ItemListener radioButtonItemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
JRadioButton temp = (JRadioButton) e.getSource();
if (temp.isSelected()) {
selectSpecified = true;
showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%"))));
selectSpecified = false;
}
}
};
private void refreshSlider(int val) {
showValue = val;
if (showValue > HUNDRED) {
slider.setValue((int) (showValue + TWO_HUNDRED) / SIX);
} else if (showValue < HUNDRED) {
slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT));
} else {
slider.setValue(HALF_HUNDRED);
}
}
private void refreshBottun(int val) {
showValButton.setText(val + "%");
private void refreshSlider() {
slider.setValue(calSliderValue(showValue));
}
public double getResolutionTimes() {
return this.resolutionTimes;
private int calSliderValue(int value) {
int result;
if (value > HUNDRED) {
result = (value + TWO_HUNDRED) / SIX;
} else if (value < HUNDRED) {
result = (int) ((value - TEN) / ONEPOINTEIGHT);
} else {
result = HALF_HUNDRED;
}
return result;
}
public int getshowValue() {
return this.showValue;
}
public static double divide(double v1, double v2, int scale) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
@ -362,30 +229,28 @@ public class JFormSliderPane extends JPanel {
private ActionListener buttonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showValue = (int) showValSpinner.getValue();
isButtonOrIsTxt = true;
if ("less".equals(e.getActionCommand())) {
int newDownVal = showValue - TEN;
if (newDownVal >= TEN) {
showValue = newDownVal;
showValSpinner.setValue(newDownVal);
} else {
showValue = newDownVal;
showValSpinner.setValue(TEN);
showValue = TEN;
}
refreshShowValueFieldText();
refreshSlider();
}
if ("more".equals(e.getActionCommand())) {
int newUpVal = showValue + TEN;
if (newUpVal <= FOUR_HUNDRED) {
showValue = newUpVal;
showValSpinner.setValue(newUpVal);
} else {
showValue = newUpVal;
showValSpinner.setValue(FOUR_HUNDRED);
showValue = TEN;
}
refreshShowValueFieldText();
refreshSlider();
}
isButtonOrIsTxt = true;
customButton.setSelected(true);
}
};
@ -396,37 +261,26 @@ public class JFormSliderPane extends JPanel {
} else if (value < HALF_HUNDRED) {
times = (int) Math.round(ONEPOINTEIGHT * value + TEN);
} else {
times = (int) (SIX * value - TWO_HUNDRED);
times = SIX * value - TWO_HUNDRED;
}
}
public JSpinner getShowVal() {
return this.showValSpinner;
public int getShowValue() {
return this.showValue;
}
public UIRadioButton getSelfAdaptButton() {
return this.selfAdaptButton;
public void setShowValue(int value) {
showValue = value;
showValFieldChange();
}
private void popupDialog() {
Point btnCoords = upButton.getLocationOnScreen();
if (dialog == null) {
dialog = new FormPopupPane(upButton, dialogContentPanel);
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
}
} else {
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
} else {
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
}
}
public void addValueChangeListener(ChangeListener changeListener){
this.slider.addChangeListener(changeListener);
}
public static void main(String[] args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -440,16 +294,3 @@ public class JFormSliderPane extends JPanel {
}
}
class FormPopupPane extends JPopupMenu {
private static final int DIALOG_WIDTH = 157;
private static final int DIALOG_HEIGHT = 172;
FormPopupPane(UIButton b, JPanel dialogContentPanel) {
this.add(dialogContentPanel, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
this.setBackground(new Color(245, 245, 247));
}
}

51
designer-base/src/test/java/com/fr/design/mainframe/JFormSliderPaneTest.java

@ -0,0 +1,51 @@
package com.fr.design.mainframe;
import com.fr.invoke.Reflect;
import org.junit.Assert;
import org.junit.Test;
/**
* Created by kerry on 2020-07-28
*/
public class JFormSliderPaneTest {
@Test
public void testParseInputValue() {
JFormSliderPane sliderPane = new JFormSliderPane();
int result = Reflect.on(sliderPane).call("parseInputValue", "100%").get();
Assert.assertEquals(100, result);
result = Reflect.on(sliderPane).call("parseInputValue", "50%").get();
Assert.assertEquals(50, result);
result = Reflect.on(sliderPane).call("parseInputValue", "50").get();
Assert.assertEquals(50, result);
result = Reflect.on(sliderPane).call("parseInputValue", "50abc").get();
Assert.assertEquals(100, result);
}
@Test
public void testGetPreferredValue() {
JFormSliderPane sliderPane = new JFormSliderPane();
int result = Reflect.on(sliderPane).call("getPreferredValue", 100).get();
Assert.assertEquals(100, result);
result = Reflect.on(sliderPane).call("getPreferredValue", 0).get();
Assert.assertEquals(10, result);
result = Reflect.on(sliderPane).call("getPreferredValue", 1000).get();
Assert.assertEquals(400, result);
}
@Test
public void testCalSliderValue() {
JFormSliderPane sliderPane = new JFormSliderPane();
int result = Reflect.on(sliderPane).call("calSliderValue", 10).get();
Assert.assertEquals(0, result);
result = Reflect.on(sliderPane).call("calSliderValue", 90).get();
Assert.assertEquals(44, result);
result = Reflect.on(sliderPane).call("calSliderValue", 100).get();
Assert.assertEquals(50, result);
result = Reflect.on(sliderPane).call("calSliderValue", 200).get();
Assert.assertEquals(66, result);
result = Reflect.on(sliderPane).call("calSliderValue", 400).get();
Assert.assertEquals(100, result);
}
}

15
designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java

@ -35,18 +35,19 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
* @param creator 组件
*/
public void fix(XCreator creator) {
FRBorderLayout layout = (FRBorderLayout)container.getFRLayout();
FRBorderLayout layout = (FRBorderLayout) container.getFRLayout();
Object constraints = layout.getConstraints(creator);
double scale = container.getScale();
if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) {
((XWBorderLayout)container).toData().setNorthSize(creator.getHeight());
((XWBorderLayout) container).toData().setNorthSize((int) (creator.getHeight() / scale));
} else if (ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) {
((XWBorderLayout)container).toData().setSouthSize(creator.getHeight());
((XWBorderLayout) container).toData().setSouthSize((int) (creator.getHeight() / scale));
} else if (ComparatorUtils.equals(constraints, BorderLayout.EAST)) {
((XWBorderLayout)container).toData().setEastSize(creator.getWidth());
((XWBorderLayout) container).toData().setEastSize((int) (creator.getWidth() / scale));
} else if (ComparatorUtils.equals(constraints, BorderLayout.WEST)) {
((XWBorderLayout)container).toData().setWestSize(creator.getWidth());
((XWBorderLayout) container).toData().setWestSize((int) (creator.getWidth() / scale));
} else {
return;
return;
}
container.recalculateChildrenPreferredSize();
}
@ -185,4 +186,4 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
return new FRBorderLayoutConstraints(container, creator);
}
}
}

23
designer-form/src/main/java/com/fr/design/designer/creator/XButton.java

@ -147,7 +147,7 @@ public class XButton extends XWidgetCreator {
public void propertyChange() {
FreeButton button = (FreeButton) data;
if (button.getFont() != null) {
contentLabel.setFont(button.getFont().applyResolutionNP(
setContentLabelFont(button.getFont().applyResolutionNP(
FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground());
}
@ -230,7 +230,7 @@ public class XButton extends XWidgetCreator {
if (!button.isCustomStyle()) {
l.setBorder(BorderFactory.createLineBorder(new Color(148, 148, 148)));
bg = DEFAULTBG;
contentLabel.setFont(DEFAULTFT);
setContentLabelFont(DEFAULTFT);
contentLabel.setForeground(DEFAULTFOREGROUNDCOLOR);
editor.setLayout(new BorderLayout());
editor.add(l, BorderLayout.CENTER);
@ -239,7 +239,7 @@ public class XButton extends XWidgetCreator {
editor.setLayout(new BorderLayout());
editor.add(l,BorderLayout.CENTER);
if (button.getFont() != null) {
contentLabel.setFont(button.getFont().applyResolutionNP(
setContentLabelFont(button.getFont().applyResolutionNP(
FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground());
}
@ -302,11 +302,26 @@ public class XButton extends XWidgetCreator {
setButtonText(button.getText());
checkButonType();
if (button.getFont() != null) {
contentLabel.setFont(button.getFont().applyResolutionNP(
setContentLabelFont(button.getFont().applyResolutionNP(
FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground());
}
}
private void setContentLabelFont(Font font) {
float size = (float) (font.getSize() * getScale());
contentLabel.setFont(font.deriveFont(size));
}
public void setScale(double scale){
super.setScale(scale);
FreeButton button = (FreeButton) data;
if (button.getFont() != null) {
setContentLabelFont(button.getFont().applyResolutionNP(
FontTransformUtil.getDesignerFontResolution()));
}else {
setContentLabelFont(DEFAULTFT);
}
}
}

9
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -49,6 +49,7 @@ import java.util.Set;
*
*/
public abstract class XCreator extends JPanel implements XComponent, XCreatorTools {
private double scale = 1.0;
protected static final Border DEFALUTBORDER = BorderFactory.createLineBorder(new Color(210, 210, 210), 1);
public static final Dimension SMALL_PREFERRED_SIZE = new Dimension(80, 21);
@ -102,6 +103,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
}
}
public double getScale() {
return scale;
}
public void setScale(double scale) {
this.scale = scale;
}
/**
* 初始化组件大小
*/

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

@ -17,6 +17,7 @@ import com.fr.design.mainframe.widget.renderer.LabelHorizontalAlignmentRenderer;
import com.fr.form.ui.Label;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.FRFont;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter;
@ -94,8 +95,11 @@ public class XLabel extends XWidgetCreator {
}
if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create();
FRFont font = label.getFont();
float fontsize = (float) (font.getSize() * this.getScale());
BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), label.getWidgetValue()
.toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign())
.toString(), Style.getInstance(font.applySize(fontsize))
.deriveHorizontalAlignment(label.getTextalign())
.deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP)
.deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE),
FontTransformUtil.getDesignerFontResolution());

4
designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java

@ -59,8 +59,10 @@ public class XTextArea extends XFieldEditor {
TextArea area = (TextArea) data;
if (area.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create();
FRFont font = FRFont.getInstance();
float fontsize = (float) (font.getSize() * this.getScale());
BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), area.getWidgetValue()
.toString(), Style.getInstance(FRFont.getInstance()).deriveHorizontalAlignment(Constants.LEFT)
.toString(), Style.getInstance(font.applySize(fontsize)).deriveHorizontalAlignment(Constants.LEFT)
.deriveVerticalAlignment(SwingConstants.TOP)
.deriveTextStyle(Style.TEXTSTYLE_WRAPTEXT), ScreenResolution.getScreenResolution());
}

4
designer-form/src/main/java/com/fr/design/designer/creator/XTextEditor.java

@ -67,8 +67,10 @@ public class XTextEditor extends XWrapperedFieldEditor {
TextEditor area = (TextEditor) data;
if (area.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create();
FRFont font = FRFont.getInstance();
float fontsize = (float) (font.getSize() * this.getScale());
BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), area.getWidgetValue()
.toString(), Style.getInstance(FRFont.getInstance()).deriveHorizontalAlignment(Constants.LEFT)
.toString(), Style.getInstance(font.applySize(fontsize)).deriveHorizontalAlignment(Constants.LEFT)
.deriveTextStyle(Style.TEXTSTYLE_SINGLELINE), ScreenResolution.getScreenResolution());
}
}

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

@ -30,6 +30,8 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.FRScreen;
import com.fr.general.IOUtils;
@ -397,6 +399,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
return;
}
XWidgetCreator creator = (XWidgetCreator) e.getChild();
creator.setScale(this.getScale());
WAbsoluteLayout wabs = this.toData();
if (!creator.acceptType(XWFitLayout.class)) {
creator.setDirections(Direction.ALL);
@ -602,4 +605,17 @@ public class XWAbsoluteLayout extends XLayoutContainer {
return super.getWidgetPropertyUIProviders();
}
}
public void adjustCompSize(double percent) {
double p = percent + 1;
WAbsoluteLayout absoluteLayout = this.toData();
for (int i = 0; i < this.getComponentCount(); i++) {
XCreator component = (XCreator) this.getComponent(i);
CRBoundsWidget boundsWidget = absoluteLayout.getBoundsWidget(component.toData());
Rectangle rec = new Rectangle(boundsWidget.getBounds());
component.adjustCompSize(percent);
component.setBounds((int) (rec.x * p), (int) (rec.y * p), (int) (rec.width * p), (int) (rec.height * p));
}
}
}

56
designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java

@ -126,14 +126,14 @@ public class XWBorderLayout extends XLayoutContainer {
WBorderLayout wlayout = this.toData();
Object constraints = wlayout.getConstraints(wgt);
Dimension d = new Dimension();
if (ComparatorUtils.equals(WBorderLayout.NORTH,constraints)) {
d.height = wlayout.getNorthSize();
} else if (ComparatorUtils.equals(WBorderLayout.SOUTH,constraints)) {
d.height = wlayout.getSouthSize();
} else if (ComparatorUtils.equals(WBorderLayout.EAST,constraints)) {
d.width = wlayout.getEastSize();
} else if (ComparatorUtils.equals(WBorderLayout.WEST,constraints)) {
d.width = wlayout.getWestSize();
if (ComparatorUtils.equals(WBorderLayout.NORTH, constraints)) {
d.height = (int) (wlayout.getNorthSize() * getScale());
} else if (ComparatorUtils.equals(WBorderLayout.SOUTH, constraints)) {
d.height = (int) (wlayout.getSouthSize() * getScale());
} else if (ComparatorUtils.equals(WBorderLayout.EAST, constraints)) {
d.width = (int) (wlayout.getEastSize() * getScale());
} else if (ComparatorUtils.equals(WBorderLayout.WEST, constraints)) {
d.width = (int) (wlayout.getWestSize() * getScale());
}
return d;
}
@ -203,8 +203,40 @@ public class XWBorderLayout extends XLayoutContainer {
}
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRBorderLayoutAdapter(this);
}
@Override
public LayoutAdapter getLayoutAdapter() {
return new FRBorderLayoutAdapter(this);
}
/**
* 自适应布局的缩放
*
* @param percent 百分比
*/
public void adjustCompSize(double percent) {
for (int i = 0; i < this.getComponentCount(); i++) {
XCreator creator = this.getXCreator(i);
WBorderLayout wlayout = this.toData();
Object constraints = wlayout.getConstraints(creator.toData());
if (ComparatorUtils.equals(BorderLayout.NORTH, constraints)) {
int northSize = (int) (this.toData().getNorthSize() * this.getScale());
Dimension dim = creator.getSize();
creator.setPreferredSize(new Dimension(dim.width, northSize));
} else if (ComparatorUtils.equals(BorderLayout.SOUTH, constraints)) {
int southSize = (int) (this.toData().getSouthSize() * this.getScale());
Dimension dim = creator.getSize();
creator.setPreferredSize(new Dimension(dim.width, southSize));
} else if (ComparatorUtils.equals(BorderLayout.EAST, constraints)) {
int eastSize = (int) (this.toData().getEastSize() * this.getScale());
Dimension dim = creator.getSize();
creator.setPreferredSize(new Dimension(eastSize, dim.height));
} else if (ComparatorUtils.equals(BorderLayout.WEST, constraints)) {
int westSize = (int) (this.toData().getWestSize() * this.getScale());
Dimension dim = creator.getSize();
creator.setPreferredSize(new Dimension(westSize, dim.height));
}
}
}
}

86
designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java

@ -18,6 +18,7 @@ import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.general.FRLogger;
import com.fr.general.FRScreen;
import com.fr.stable.ArrayUtils;
@ -129,6 +130,7 @@ public class XWFitLayout extends XLayoutContainer {
}
}
/**
* 直接拖动滑条改变整体像素大小时不用考虑控件的最小高度宽度内部组件全部一起缩小放大
* 只是界面显示大小改变不改变对应的BoundsWidget大小
@ -137,32 +139,28 @@ public class XWFitLayout extends XLayoutContainer {
public void adjustCreatorsWhileSlide(double percent) {
int count = this.getComponentCount();
if (count == 0) {
Dimension size = new Dimension(this.getSize());
size.width += size.width*percent;
size.height += size.height*percent;
Dimension size = new Dimension(this.toData().getContentWidth(), this.toData().getContentHeight());
size.width += size.width * percent;
size.height += size.height * percent;
this.setSize(size);
return;
}
// 初始化时还未加间隔
if (hasCalGap) {
moveContainerMargin();
moveCompInterval(backupGap);
LayoutUtils.layoutContainer(this);
}
int containerW = 0;
int containerH = 0;
int[] hors = getHors(false);
int[] veris = getVeris(false);
PaddingMargin margin = toData().getMargin();
for (int i=0; i<count; i++) {
int[] hors = getDataHors();
int[] veris = getDataVeris();
PaddingMargin margin = new PaddingMargin();
for (int i = 0; i < count; i++) {
XCreator creator = getXCreator(i);
WFitLayout fitLayout = this.toData();
CRBoundsWidget boundsWidget = fitLayout.getBoundsWidget(creator.toData());
// 百分比和updateBoundsWidget时都会调整大小
// 子组件非空时,调整界面大小、 撤销、再次打开表单,都会按屏幕百分比调整,此时必须考虑内边距
Rectangle rec = modifyCreatorPoint(creator.getBounds(), percent, hors, veris);
Rectangle rec = modifyCreatorPoint(boundsWidget.getBounds(), percent, hors, veris);
if (rec.x == margin.getLeft()) {
containerH += rec.height;
}
if (rec.y == margin.getTop()) {
if (rec.y == margin.getTop()) {
containerW += rec.width;
}
creator.setBounds(rec);
@ -170,15 +168,12 @@ public class XWFitLayout extends XLayoutContainer {
}
// 布局内部组件放大缩小后,都是乘以百分比后取整,可能会产生空隙,此处调整容器
this.setSize(
containerW + (int)(margin.getLeft() * (1.0+percent) + margin.getRight() * (1.0+percent)),
containerH + (int)(margin.getTop() * (1.0+percent) + margin.getBottom() * (1.0+percent))
containerW + (int) (margin.getLeft() * (1.0 + percent) + margin.getRight() * (1.0 + percent)),
containerH + (int) (margin.getTop() * (1.0 + percent) + margin.getBottom() * (1.0 + percent))
);
updateCreatorsBackupBound();
// 间隔也按显示大小比例调整
if (!hasCalGap) {
moveContainerMargin();
addCompInterval(getAcualInterval());
}
addCompInterval(getAcualInterval());
LayoutUtils.layoutContainer(this);
}
@ -186,6 +181,7 @@ public class XWFitLayout extends XLayoutContainer {
* 调整控件的point和size,避免拖动滑块出现空隙
*/
private Rectangle modifyCreatorPoint(Rectangle rec, double percent, int[] hors, int[] veris) {
rec = new Rectangle(rec);
int xIndex = 0, yIndex = 0;
PaddingMargin margin = toData().getMargin();
Rectangle bound = new Rectangle(rec);
@ -264,6 +260,41 @@ public class XWFitLayout extends XLayoutContainer {
return ArrayUtils.toPrimitive(posX.toArray(new Integer[]{posX.size()}));
}
public int[] getDataHors() {
List<Integer> posX = new ArrayList<Integer>();
// 保存实际大小时,组件大小已经去除内边距,此处也判断下
posX.add(0);
int width = this.toData().getContainerWidth();
posX.add(width);
for (int i = 0, len = this.toData().getWidgetCount(); i < len; i++) {
CRBoundsWidget widget = (CRBoundsWidget) this.toData().getWidget(i);
Rectangle rec = widget.getBounds();
if (!posX.contains(rec.x)) {
posX.add(rec.x);
}
}
Collections.sort(posX);
return ArrayUtils.toPrimitive(posX.toArray(new Integer[]{posX.size()}));
}
public int[] getDataVeris() {
List<Integer> posY = new ArrayList<Integer>();
// 保存实际大小时,组件大小已经去除内边距,此处也判断下
posY.add(0);
int height = this.toData().getContainerHeight();
posY.add(height);
for (int i = 0, len = this.toData().getWidgetCount(); i < len; i++) {
CRBoundsWidget boundsWidget = (CRBoundsWidget) this.toData().getWidget(i);
Rectangle rec = boundsWidget.getBounds();
if (!posY.contains(rec.y)) {
posY.add(rec.y);
}
}
Collections.sort(posY);
return ArrayUtils.toPrimitive(posY.toArray(new Integer[]{posY.size()}));
}
/**
* 获取内部组件纵坐标值
* @param isActualSize 实际大小
@ -290,6 +321,7 @@ public class XWFitLayout extends XLayoutContainer {
return ArrayUtils.toPrimitive(posY.toArray(new Integer[]{posY.size()}));
}
/**
* 是否能缩小
* @param percent 百分比
@ -860,12 +892,14 @@ public class XWFitLayout extends XLayoutContainer {
}
super.add(comp, constraints);
XCreator creator = (XCreator) comp;
creator.setScale(this.getScale());
dealDirections(creator, false);
}
private void add(Component comp, Object constraints, boolean isInit) {
super.add(comp, constraints);
XCreator creator = (XCreator) comp;
creator.setScale(this.getScale());
dealDirections(creator, isInit);
}
@ -1331,4 +1365,14 @@ public class XWFitLayout extends XLayoutContainer {
}
}
}
/**
* 自适应布局的缩放
*
* @param percent 百分比
*/
@Override
public void adjustCompSize(double percent) {
this.adjustCreatorsWhileSlide(percent);
}
}

6
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java

@ -237,6 +237,7 @@ public class XCardSwitchButton extends XButton {
layout.setIndex(--tabFitIndex);
}
}
tagLayout.setTabsAndAdjust();
}
@ -337,7 +338,8 @@ public class XCardSwitchButton extends XButton {
String titleText = button.getText();
this.setButtonText(titleText);
FRFont font = widgetTitle.getFrFont();
FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST);
int fontsize = font.getSize() + FONT_SIZE_ADJUST;
FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(), (float) (fontsize * getScale()));
UILabel label = this.getContentLabel();
label.setFont(newFont);
label.setForeground(font.getForeground());
@ -459,7 +461,7 @@ public class XCardSwitchButton extends XButton {
TitlePacker title = getWidgetTitle();
FRFont font = title.getFrFont();
int fontSize = font.getSize() + FONT_SIZE_ADJUST;
FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), fontSize);
FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), (float) (fontSize * getScale()));
FontMetrics fm = GraphHelper.getFontMetrics(newFont);
for (int i = 0; i < titleText.length(); i++) {
titleStringBuf.append(titleText.charAt(i));

2
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -290,7 +290,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
@Override
public void doLayout() {
setTabsAndAdjust();
//设置布局
super.doLayout();
}
@ -382,7 +381,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} else {
adjustTabsV(parent, tabLength, cardWidth, cardHeight);
}
fixTitleLayout(parent);
}
public void adjustTabsH(XLayoutContainer parent, int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {

83
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -8,15 +8,11 @@ import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI;
import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.editors.ButtonTypeEditor;
import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor;
import com.fr.design.utils.gui.LayoutUtils;
@ -44,7 +40,7 @@ import java.beans.IntrospectionException;
* @date 2014-6-23
*/
public class XWTabFitLayout extends XWFitLayout {
private static final int MIN_SIZE = 0;
private static final int WIDTH_SIDE_OFFSET = 57;
@ -101,7 +97,7 @@ public class XWTabFitLayout extends XWFitLayout {
public XWTabFitLayout(){
this(new WTabFitLayout(), new Dimension());
}
public XWTabFitLayout(WTabFitLayout widget, Dimension initSize) {
super(widget, initSize);
}
@ -252,13 +248,13 @@ public class XWTabFitLayout extends XWFitLayout {
public LayoutAdapter getLayoutAdapter() {
return new FRTabFitLayoutAdapter(this);
}
/**
* tab布局里删除XWTabFitLayout对应的tab按钮
*
*
* @param creator 当前组件
* @param designer 表单设计器
*
*
*/
@Override
public void deleteRelatedComponent(XCreator creator, FormDesigner designer){
@ -288,15 +284,15 @@ public class XWTabFitLayout extends XWFitLayout {
deleteTabLayout(mainLayout,designer);
return;
}
//刷新tab按钮和tabFitLayout的index
refreshIndex(tag,cardLayout,index);
LayoutUtils.layoutRootContainer(designer.getRootComponent());
}
private void deleteTabLayout(XLayoutContainer mainLayout, FormDesigner designer){
SelectionModel selectionModel = designer.getSelectionModel();
if(mainLayout != null){
@ -323,7 +319,7 @@ public class XWTabFitLayout extends XWFitLayout {
}
}
}
/**
* tab布局里切换到相应的tab按钮
* @param comp 当前组件
@ -344,44 +340,37 @@ public class XWTabFitLayout extends XWFitLayout {
button.setShowButton(button.getIndex()==index);
}
}
/**
* 寻找最近的为自适应布局的父容器
*
*
* @return 布局容器
*
*
*
* @date 2014-12-30-下午3:15:28
*
*
*/
@Override
public XLayoutContainer findNearestFit(){
XLayoutContainer parent = this.getBackupParent();
return parent == null ? null : parent.findNearestFit();
}
/**
* 非顶层自适应布局的缩放
* @param percent 百分比
*/
@Override
public void adjustCompSize(double percent) {
this.adjustCreatorsWhileSlide(percent);
}
}
/**
* 该布局需要隐藏无需对边框进行操作
* @param border 边框
*
*
*/
public void setBorder(Border border) {
return;
}
/**
* 按照百分比缩放内部组件宽度
*
*
* @param percent 宽度变化的百分比
*/
@Override
@ -397,7 +386,7 @@ public class XWTabFitLayout extends XWFitLayout {
moveCompInterval(getAcualInterval());
updateCompsWidget();
}
layoutWidthResize(percent);
layoutWidthResize(percent);
if (percent < 0 && this.getNeedAddWidth() > 0) {
this.setSize(this.getWidth()+this.getNeedAddWidth(), this.getHeight());
modifyEdgemostCreator(true);
@ -410,8 +399,8 @@ public class XWTabFitLayout extends XWFitLayout {
updateWidgetBackupBounds();
LayoutUtils.layoutContainer(this);
}
/**
* 布局容器高度手动修改时
* 同时调整容器内的组件们,缩小时需要考虑有的组件高度不满足缩小高度
@ -441,13 +430,13 @@ public class XWTabFitLayout extends XWFitLayout {
updateWidgetBackupBounds();
LayoutUtils.layoutContainer(this);
}
@Override
public XLayoutContainer getOuterLayout(){
XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent();
return cardLayout.getBackupParent();
}
// 更新内部组件的widget
private void updateCompsWidget(){
for(int m=0;m<this.getComponentCount();m++){
@ -487,7 +476,7 @@ public class XWTabFitLayout extends XWFitLayout {
this.setxCardSwitchButton((XCardSwitchButton)xCreator);
}
}
/**
* 去除原有的间隔
* @param gap 间隔
@ -498,11 +487,11 @@ public class XWTabFitLayout extends XWFitLayout {
return;
}
int val = gap/2;
// 比较组件大小和tab布局的大小的参照宽高
double referWidth = getReferWidth();
double referHeight = getReferHeight();
for (int i=0, len=this.getComponentCount(); i<len; i++) {
Component comp = this.getComponent(i);
Rectangle rec = comp.getBounds();
@ -523,10 +512,10 @@ public class XWTabFitLayout extends XWFitLayout {
}
comp.setBounds(bound);
}
this.hasCalGap = false;
}
private double getReferWidth(){
if(referDim != null){
return referDim.getWidth();
@ -534,7 +523,7 @@ public class XWTabFitLayout extends XWFitLayout {
return this.getWidth();
}
}
private double getReferHeight(){
if(referDim != null){
return referDim.getHeight();
@ -542,8 +531,8 @@ public class XWTabFitLayout extends XWFitLayout {
return this.getHeight();
}
}
/**
* 间隔大于0时界面处加上间隔
* 界面的间隔是针对显示实际保存的大小不受间隔影响
@ -578,7 +567,7 @@ public class XWTabFitLayout extends XWFitLayout {
}
comp.setBounds(bound);
}
this.hasCalGap = true;
}

189
designer-form/src/main/java/com/fr/design/mainframe/FormArea.java

@ -2,16 +2,13 @@ package com.fr.design.mainframe;
import com.fr.base.ScreenResolution;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.fun.FormAdaptiveConfigUIProcessor;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
@ -28,8 +25,10 @@ import com.fr.general.FRScreen;
import com.fr.stable.AssistUtils;
import javax.swing.AbstractAction;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@ -46,13 +45,17 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
public class FormArea extends JComponent implements ScrollRulerComponent {
private static final double SLIDER_FLOAT = 400.0;
private static final double SLIDER_MIN = 10.0;
private static final String SCALE_PLUS_COMMAND = "scale_plus";
private static final String SCALE_MINUS_COMMAND = "scale_minus";
public static final double DEFAULT_SLIDER = 100.0;
private static final int ROTATIONS = 50;
private static final int SHOWVALMAX = 400;
@ -72,8 +75,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private UINumberField heightPane;
private JFormSliderPane slidePane;
private boolean isValid = true;
// 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER;
private int resolution = ScreenResolution.getScreenResolution();
private double screenValue;
@ -112,16 +113,33 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
addFormRuler();
}
this.setFocusTraversalKeysEnabled(false);
this.designer.addMouseWheelListener(showValSpinnerMouseWheelListener);
this.addMouseWheelListener(showValSpinnerMouseWheelListener);
registerShortCutKey();
}
private boolean openSliderZoom(){
FormAdaptiveConfigUIProcessor adaptiveConfigUI = ExtraDesignClassManager.getInstance().getSingle(FormAdaptiveConfigUIProcessor.MARK_STRING);
if (adaptiveConfigUI != null) {
return adaptiveConfigUI.openFormSliderZoom();
}
return false;
/**
* 注册缩放快捷键
* mac: command + command -
* windows: ctr + ctr -
*/
private void registerShortCutKey() {
this.registerKeyboardAction(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int old_resolution = slidePane.getShowValue();
slidePane.setShowValue(old_resolution + SHOWVALMIN);
}
}, SCALE_PLUS_COMMAND, KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, DEFAULT_MODIFIER), WHEN_IN_FOCUSED_WINDOW);
this.registerKeyboardAction(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
int old_resolution = slidePane.getShowValue();
slidePane.setShowValue(old_resolution - SHOWVALMIN);
}
}, SCALE_MINUS_COMMAND, KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, DEFAULT_MODIFIER), WHEN_IN_FOCUSED_WINDOW);
}
public void onMobileAttrModified() {
FormMobileAttr formMobileAttr = designer.getTarget().getFormMobileAttr();
if (formMobileAttr.isMobileOnly()) {
@ -138,12 +156,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
public void mouseWheelMoved(MouseWheelEvent e) {
if (InputEventBaseOnOS.isControlDown(e)) {
int dir = e.getWheelRotation();
int old_resolution = (int) slidePane.getShowVal().getValue();
slidePane.getShowVal().setValue(old_resolution - (dir * SHOWVALMIN));
int old_resolution = slidePane.getShowValue();
slidePane.setShowValue(old_resolution - (dir * SHOWVALMIN));
}
}
};
/**
* 增加表单的页面大小控制界面包括手动修改和滑块拖动
*/
@ -170,14 +190,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
slidePane}}, rowSize, columnSize, RESIZE_PANE_GAP);
this.add(FormRulerLayout.BOTTOM, resizePane);
setWidgetsConfig();
boolean needOpenSliderZoom = openSliderZoom();
// 先初始话滑块及对应事件,然后获取分辨率调整容器的显示大小
slidePane.setEnabled(needOpenSliderZoom);
slidePane.setVisible(needOpenSliderZoom);
if (needOpenSliderZoom) {
initTransparent();
}
slidePane.setEnabled(true);
slidePane.setVisible(true);
initCalculateSize();
slidePane.addValueChangeListener(showValSpinnerChangeListener);
}
private void setWidgetsConfig() {
@ -192,21 +209,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
addHeightPaneListener();
}
private void initTransparent() {
initCalculateSize();
slidePane.getShowVal().addChangeListener(showValSpinnerChangeListener);
}
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner) e.getSource()).getValue();
double value = slidePane.getShowValue();
value = value > SHOWVALMAX ? SHOWVALMAX : value;
value = value < SHOWVALMIN ? SHOWVALMIN : value;
JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jf.getFormDesign().setResolution((int) value);
jf.getFormDesign().getArea().resolution = (int) value;
reCalculateRoot(value, true);
scale((int) value);
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (form != null) {
form.fireTargetModified();
@ -214,6 +224,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
}
};
private void scale(int value){
this.designer.setResolution(value);
this.designer.getArea().resolution = value;
reCalculateRoot(value, true);
}
/**
* 返回当前的屏幕分辨率对应的百分比值
*
@ -238,7 +254,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
this.screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue();
XLayoutContainer root = FormArea.this.designer.getRootComponent();
// 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整
// slidePane.populateBean(screenValue);
if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root;
if ( !AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) {
@ -246,7 +261,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
} else {
// 组件间隔啊
// REPORT-2585 原有的逻辑导致嵌套的tab中的间隔加不上去,会在后续拖动的过程中出问题
reCalculateDefaultRoot(screenValue, true);
reCalculateDefaultRoot();
}
}
LayoutUtils.layoutContainer(root);
@ -366,16 +381,14 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
* 修改大小后再根据屏幕分辨率调整下
*/
private void doReCalculateRoot(int width, int height, XWFitLayout layout) {
// double value = slidePane.updateBean();
//重置滑块的值为默认值100
START_VALUE = DEFAULT_SLIDER;
if ( AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) {
layout.getParent().setSize(width, height + designer.getParaHeight());
FormArea.this.validate();
} else {
layout.setBackupGap(screenValue / DEFAULT_SLIDER);
reCalculateRoot(screenValue, false);
}
reCalculateRoot(slidePane.getShowValue(), true);
}
/**
@ -385,71 +398,60 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
* @param value
*/
private void reCalculateRoot(double value, boolean needCalculateParaHeight) {
if ( AssistUtils.equals(value, START_VALUE) ) {
return;
}
double percent = (value - START_VALUE) / START_VALUE;
double percent = (value - DEFAULT_SLIDER) / DEFAULT_SLIDER;
double scale = value / DEFAULT_SLIDER;
XLayoutContainer root = FormArea.this.designer.getRootComponent();
if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root;
layout.setContainerPercent(value / DEFAULT_SLIDER);
layout.setContainerPercent(scale);
layout.adjustCompSize(percent);
traverAndAdjust(layout, percent);
layout.adjustCreatorsWhileSlide(percent);
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
Dimension d = new Dimension(layout.getWidth(), layout.getHeight());
XWBorderLayout parent = (XWBorderLayout) layout.getParent();
root.setScale(scale);
// 自适应布局的父层是border
if (layout.getParent() != null) {
int paraHeight = designer.getParaHeight();
if (needCalculateParaHeight && paraHeight > 0) {
designer.setParaHeight(paraHeight);
XWBorderLayout parent = (XWBorderLayout) layout.getParent();
parent.toData().setNorthSize(paraHeight);
if (parent != null) {
parent.setScale(scale);
int paraHeight = parent.toData().getNorthSize();
XLayoutContainer paraComponent = designer.getParaComponent();
if (needCalculateParaHeight && paraComponent != null) {
paraComponent.setScale(scale);
this.designer.setParaHeight(paraHeight);
paraComponent.setPreferredSize(new Dimension(d.width, this.designer.getParaHeight()));
paraComponent.adjustCompSize( percent);
parent.removeAll();
parent.add(designer.getParaComponent(), WBorderLayout.NORTH);
parent.add(designer.getRootComponent(), WBorderLayout.CENTER);
parent.add(paraComponent, WBorderLayout.NORTH);
parent.add(root, WBorderLayout.CENTER);
root.setBounds(0, this.designer.getParaHeight(), d.width, d.height);
}
layout.getParent().setSize(d.width, d.height + paraHeight);
parent.setSize(d.width, d.height + this.designer.getParaHeight());
// 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea
FormArea.this.validate();
LayoutUtils.layoutRootContainer(designer.getRootComponent());
}
START_VALUE = value;
}
}
/**
* 按照界面大小的百分比值调整root大小
*
* @param needCalculateParaHeight 是否需要调整参数界面高度
* @param value
*/
private void reCalculateDefaultRoot(double value, boolean needCalculateParaHeight) {
private void reCalculateDefaultRoot() {
XLayoutContainer root = FormArea.this.designer.getRootComponent();
if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root;
layout.setContainerPercent(1.0);
traverAndAdjust(layout, 0.0);
layout.adjustCreatorsWhileSlide(0.0);
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
Dimension d = new Dimension(layout.getWidth(), layout.getHeight());
// 自适应布局的父层是border
if (layout.getParent() != null) {
int paraHeight = designer.getParaHeight();
if (needCalculateParaHeight && paraHeight > 0) {
designer.setParaHeight(paraHeight);
XWBorderLayout parent = (XWBorderLayout) layout.getParent();
parent.toData().setNorthSize(paraHeight);
parent.removeAll();
parent.add(designer.getParaComponent(), WBorderLayout.NORTH);
parent.add(designer.getRootComponent(), WBorderLayout.CENTER);
}
layout.getParent().setSize(d.width, d.height + paraHeight);
// 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea
FormArea.this.validate();
Dimension dimension = layout.getSize();
double widthScale = 960D / dimension.width;
double heightScale = 960D / dimension.height;
final double scaleValue = Math.min(widthScale, heightScale);
int value = (int) (scaleValue * 100);
slidePane.setShowValue(value);
if (value == 100) {
return;
}
scale(value);
}
}
@ -459,6 +461,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
Object object = creator.getComponent(i);
if (object instanceof XCreator) {
XCreator temp = (XCreator) object;
temp.setScale(1 + percent);
temp.adjustCompSize(percent);
traverAndAdjust(temp, percent);
}
@ -480,17 +483,17 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
* 鼠标滚轮事件
* 由于表单设计界面要求 容器大小大于界面时滚动条才可以拖动所以不支持滚动无限往下滚
*/
@Override
protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent evt) {
int id = evt.getID();
switch (id) {
case MouseEvent.MOUSE_WHEEL: {
onMouseWheelScroll(evt);
break;
}
default:
}
}
// @Override
// protected void processMouseWheelEvent(java.awt.event.MouseWheelEvent evt) {
// int id = evt.getID();
// switch (id) {
// case MouseEvent.MOUSE_WHEEL: {
// onMouseWheelScroll(evt);
// break;
// }
// default:
// }
// }
private void onMouseWheelScroll(MouseWheelEvent evt) {
int value = this.verScrollBar.getValue() + evt.getWheelRotation() * ROTATIONS;
@ -723,9 +726,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
* @return 百分比值
*/
public double getSlideValue() {
// return slidePane.updateBean();
//7.1.1不加缩放滑块
return this.screenValue;
return slidePane.getShowValue();
}
/**
@ -763,7 +764,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
layout.moveContainerMargin();
layout.addCompInterval(layout.getAcualInterval());
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) {
START_VALUE = DEFAULT_SLIDER;
reCalculateRoot(slide, true);
// slidePane.populateBean(slide);
}
@ -840,7 +840,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
DESIGNERWIDTH = DESIGNERWIDTH > maxWidth ? maxWidth : DESIGNERWIDTH;
DESIGNERHEIGHT = DESIGNERHEIGHT > maxHeight ? maxHeight : DESIGNERHEIGHT;
int designerLeft = left + (verScrollBar.getX() - DESIGNERWIDTH) / 2;
rec = new Rectangle(designerLeft, TOPGAP, DESIGNERWIDTH, DESIGNERHEIGHT);
int designerTop = top + (horScrollBar.getY() - DESIGNERHEIGHT) / 2;
rec = new Rectangle(designerLeft, designerTop, DESIGNERWIDTH, DESIGNERHEIGHT);
}
// designer是整个表单设计界面中的面板部分,目前只放自适应布局和参数界面。
designer.setBounds(rec);

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

@ -493,10 +493,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
public void setParaHeight(int height) {
XWBorderLayout container = (XWBorderLayout) getTopContainer();
container.toData().setNorthSize(height);
container.setSize(container.getWidth(), container.getHeight() + height - getParaHeight());
paraHeight = height;
int displayHeight = (int) (height * container.getScale());
container.setSize(container.getWidth(), container.getHeight() + displayHeight - getParaHeight());
paraHeight = displayHeight;
}
/**
* 删除参数界面
*/

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

@ -15,6 +15,8 @@ import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WParameterLayout;
import com.fr.log.FineLoggerFactory;
import java.awt.LayoutManager;
@ -232,12 +234,13 @@ public class FormSelection {
int size = selection.size();
if (size == 1) {
XCreator creator = selection.get(0);
if(creator.acceptType(XWCardTagLayout.class)){
creator = (XCreator)selection.get(0).getParent();
if (creator.acceptType(XWCardTagLayout.class)) {
creator = (XCreator) selection.get(0).getParent();
}
creator.setBounds(rec);
if (creator.acceptType(XWParameterLayout.class)) {
designer.setParaHeight((int) rec.getHeight());
double height = rec.getHeight() / creator.getScale();
designer.setParaHeight((int) height);
designer.getArea().doLayout();
}
LayoutUtils.layoutContainer(creator);

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

@ -8,6 +8,7 @@ import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.design.widget.WidgetBoundsPaneFactory;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import java.awt.Rectangle;
@ -42,15 +43,13 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane {
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
formDesigner.getSelectionModel().getSelection().backupBounds();
super.update();
Rectangle bounds = new Rectangle(creator.getBounds());
bounds.x = (int) x.getValue();
bounds.y = (int) y.getValue();
Rectangle bounds = new Rectangle((int) x.getValue(), (int) y.getValue(), (int) width.getValue(), (int) height.getValue());
if (parent == null) {
return;
}
WLayout wabs = parent.toData();
wabs.setBounds(creator.toData(), bounds);
creator.setBounds(bounds);
parent.adjustCompSize(parent.getScale() -1);
LayoutUtils.layoutContainer(creator);
XWAbsoluteLayout layout = (XWAbsoluteLayout) parent;
layout.updateBoundsWidget(creator);
@ -59,14 +58,13 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane {
@Override
public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec){
bounds.width = w;
creator.setBounds(bounds);
}
@Override
public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec){
bounds.height = h;
creator.setBounds(bounds);
}
@Override
protected String title4PopupWindow() {
return "absoluteBound";
@ -75,7 +73,12 @@ public class WidgetAbsoluteBoundPane extends WidgetBoundPane {
@Override
public void populate() {
super.populate();
Rectangle bounds = new Rectangle(creator.getBounds());
WLayout wabs = parent.toData();
CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData());
if (boundsWidget == null){
return;
}
Rectangle bounds = boundsWidget.getBounds();
x.setValue(bounds.x);
y.setValue(bounds.y);
}

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

@ -20,9 +20,8 @@ import com.fr.design.widget.WidgetBoundsPaneFactory;
import com.fr.form.ui.PaddingMargin;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
import javax.swing.JOptionPane;
import java.awt.Rectangle;
@ -46,8 +45,8 @@ public class WidgetBoundPane extends BasicPane {
}
public XLayoutContainer getParent(XCreator source) {
if(source.acceptType(XWCardTagLayout.class)){
return (XLayoutContainer)source.getParent();
if (source.acceptType(XWCardTagLayout.class)) {
return (XLayoutContainer) source.getParent();
}
XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source);
if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) {
@ -79,18 +78,24 @@ public class WidgetBoundPane extends BasicPane {
}
public void populate() {
Rectangle bounds = new Rectangle(creator.getBounds());
WLayout wabs = parent.toData();
CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData());
if (boundsWidget == null){
return;
}
Rectangle bounds = new Rectangle(boundsWidget.getBounds());
width.setValue(bounds.width);
height.setValue(bounds.height);
}
public void fix() {
Rectangle bounds = new Rectangle(creator.getBounds());
WLayout wabs = parent.toData();
CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData());
Rectangle bounds = new Rectangle(boundsWidget.getBounds());
creator.setBackupBound(creator.getBounds());
int w = (int) width.getValue();
int h = (int) height.getValue();
Rectangle rec = ComponentUtils.getRelativeBounds(parent);
WLayout wabs = parent.toData();
if (bounds.width != w) {
limitWidth(wabs, w, bounds, rec);
}
@ -101,25 +106,27 @@ public class WidgetBoundPane extends BasicPane {
public void adjustComponents(Rectangle bounds, int difference, int row) {
double scale = parent.getScale();
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
Rectangle backupBounds = getBound();
FRFitLayoutAdapter layoutAdapter = (FRFitLayoutAdapter) AdapterBus.searchLayoutAdapter(formDesigner, creator);
if (layoutAdapter != null) {
layoutAdapter.setEdit(true);
layoutAdapter.calculateBounds(backupBounds, bounds, creator, row, difference);
layoutAdapter.calculateBounds(backupBounds, new Rectangle((int) (bounds.x * scale), (int) (bounds.y * scale), (int) (bounds.width * scale), (int) (bounds.height * scale)), creator, row, difference);
}
}
public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) {
int difference = 0;
double scale = parent.getScale();
int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling());
PaddingMargin margin = wabs.getMargin();
if (bounds.width != w) {
if (bounds.width == rec.width - margin.getLeft() - margin.getRight()) {
if ((int) (bounds.width * scale) == rec.width - margin.getLeft() - margin.getRight()) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds"));
width.setValue(bounds.width);
return;
} else if (w < minWidth) {
} else if (w * scale < minWidth) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Width") + Integer.toString(minWidth));
width.setValue(bounds.width);
return;
@ -132,15 +139,16 @@ public class WidgetBoundPane extends BasicPane {
}
public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) {
double scale = parent.getScale();
int difference = 0;
PaddingMargin margin = wabs.getMargin();
int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling());
if (bounds.height != h) {
if (bounds.height == rec.height - margin.getTop() - margin.getBottom()) {
if ((int) (bounds.height * scale) == rec.height - margin.getTop() - margin.getBottom()) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds"));
height.setValue(bounds.height);
return;
} else if (h < minHeight) {
} else if (h * scale < minHeight) {
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Height") + Integer.toString(minHeight));
height.setValue(bounds.height);
return;

24
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java

@ -10,11 +10,9 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.widget.WidgetBoundsPaneFactory;
import com.fr.form.ui.container.WTabDisplayPosition;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.ComparatorUtils;
import javax.swing.JOptionPane;
import java.awt.Rectangle;
/**
@ -39,6 +37,7 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane {
if (parent == null) {
return;
}
double scale = parent.getScale();
FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner();
Rectangle parentBounds = new Rectangle(parent.getBounds());
@ -48,17 +47,17 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane {
XLayoutContainer tabLayout = creator.getTopLayout();
Rectangle rectangle = tabLayout.getBounds();
if(ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){
if(rectangle.height < size){
if(rectangle.height < size* scale){
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds"));
return;
}
parentBounds.height = size;
parentBounds.height = (int) (size * scale);
}else{
if(rectangle.width < size){
if(rectangle.width < size*scale){
FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds"));
return;
}
parentBounds.width = size;
parentBounds.width = (int) (size * scale);
}
parent.setBounds(parentBounds);
@ -76,15 +75,8 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane {
@Override
public void populate() {
WCardTagLayout tagLayout = (WCardTagLayout)creator.toData();
Rectangle bounds = new Rectangle(creator.getBounds());
WTabDisplayPosition displayPosition = tagLayout.getDisplayPosition();
if( ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){
cardTagWidth.setValue(bounds.height);
}else{
cardTagWidth.setValue(bounds.width);
}
WCardMainBorderLayout wCardMainBorderLayout = (WCardMainBorderLayout)creator.getTopLayout().toData();
cardTagWidth.setValue(wCardMainBorderLayout.getTitleSize());
}
}

Loading…
Cancel
Save