Browse Source

代码提交

feature/big-screen
kerry 4 years ago
parent
commit
ebe9b10608
  1. 17
      designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java
  2. 28
      designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java
  3. 4
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.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. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  7. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java
  8. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XNumberEditor.java
  9. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XTextArea.java
  10. 4
      designer-form/src/main/java/com/fr/design/designer/creator/XTextEditor.java
  11. 16
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  12. 56
      designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java
  13. 92
      designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java
  14. 1
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java
  15. 6
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  16. 12
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  17. 13
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java
  18. 11
      designer-form/src/main/java/com/fr/design/form/layout/FRFitLayout.java
  19. 6
      designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java
  20. 32
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  21. 25
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java
  22. 6
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  23. 71
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  24. 38
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  25. 9
      designer-form/src/main/java/com/fr/design/mainframe/FormSelection.java
  26. 17
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetAbsoluteBoundPane.java
  27. 59
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java
  28. 24
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java

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

@ -35,19 +35,18 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
* @param creator 组件 * @param creator 组件
*/ */
public void fix(XCreator creator) { public void fix(XCreator creator) {
FRBorderLayout layout = (FRBorderLayout) container.getFRLayout(); FRBorderLayout layout = (FRBorderLayout)container.getFRLayout();
Object constraints = layout.getConstraints(creator); Object constraints = layout.getConstraints(creator);
double scale = container.getScale();
if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) { if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) {
((XWBorderLayout) container).toData().setNorthSize((int) (creator.getHeight() / scale)); ((XWBorderLayout)container).toData().setNorthSize(creator.getHeight());
} else if (ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) { } else if (ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) {
((XWBorderLayout) container).toData().setSouthSize((int) (creator.getHeight() / scale)); ((XWBorderLayout)container).toData().setSouthSize(creator.getHeight());
} else if (ComparatorUtils.equals(constraints, BorderLayout.EAST)) { } else if (ComparatorUtils.equals(constraints, BorderLayout.EAST)) {
((XWBorderLayout) container).toData().setEastSize((int) (creator.getWidth() / scale)); ((XWBorderLayout)container).toData().setEastSize(creator.getWidth());
} else if (ComparatorUtils.equals(constraints, BorderLayout.WEST)) { } else if (ComparatorUtils.equals(constraints, BorderLayout.WEST)) {
((XWBorderLayout) container).toData().setWestSize((int) (creator.getWidth() / scale)); ((XWBorderLayout)container).toData().setWestSize(creator.getWidth());
} else { } else {
return; return;
} }
container.recalculateChildrenPreferredSize(); container.recalculateChildrenPreferredSize();
} }
@ -59,7 +58,7 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
* @param y 纵坐标 * @param y 纵坐标
*/ */
public void addComp(XCreator child, int x, int y) { public void addComp(XCreator child, int x, int y) {
String placement = getPlacement(child, x, y); String placement = getPlacement(child, x, y);
container.add(child, placement); container.add(child, placement);
LayoutUtils.layoutRootContainer(container); LayoutUtils.layoutRootContainer(container);
} }
@ -105,7 +104,7 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter {
int northSize = wLayout.getNorthSize(); int northSize = wLayout.getNorthSize();
int southSize = wLayout.getSouthSize(); int southSize = wLayout.getSouthSize();
int eastSize = wLayout.getEastSize(); int eastSize = wLayout.getEastSize();
int westSize = wLayout.getWestSize(); int westSize = wLayout.getWestSize();
if (y < northSize) { if (y < northSize) {
return BorderLayout.NORTH; return BorderLayout.NORTH;
} else if ((y >= northSize) && (y < (height - southSize))) { } else if ((y >= northSize) && (y < (height - southSize))) {

28
designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java

@ -17,14 +17,14 @@ import java.awt.Rectangle;
* 添加状态下的model * 添加状态下的model
*/ */
public class AddingModel { public class AddingModel {
// 当前要添加的组件 // 当前要添加的组件
private XCreator creator; private XCreator creator;
// 记录当前鼠标的位置信息 // 记录当前鼠标的位置信息
private int currentX; private int currentX;
private int currentY; private int currentY;
private boolean added; private boolean added;
public AddingModel(FormDesigner designer, XCreator xCreator) { public AddingModel(FormDesigner designer, XCreator xCreator) {
this.creator = xCreator; this.creator = xCreator;
instantiateCreator(designer); instantiateCreator(designer);
@ -32,14 +32,14 @@ public class AddingModel {
currentY = -this.creator.getWidth(); currentY = -this.creator.getWidth();
currentX = -this.creator.getHeight(); currentX = -this.creator.getHeight();
} }
/** /**
* 待说明 * 待说明
* *
* @param designer 设计器 * @param designer 设计器
*/ */
public void instantiateCreator(FormDesigner designer) { public void instantiateCreator(FormDesigner designer) {
ModelUtil.renameWidgetName(designer.getTarget(), creator); ModelUtil.renameWidgetName(designer.getTarget(), creator);
ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator); ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator);
adapter.initialize(); adapter.initialize();
@ -55,7 +55,7 @@ public class AddingModel {
currentX = x - (xCreator.getWidth() / 2); currentX = x - (xCreator.getWidth() / 2);
currentY = y - (xCreator.getHeight() / 2); currentY = y - (xCreator.getHeight() / 2);
} }
/** /**
* 隐藏当前组件的图标 * 隐藏当前组件的图标
*/ */
@ -63,7 +63,7 @@ public class AddingModel {
currentX = -this.creator.getWidth(); currentX = -this.creator.getWidth();
currentY = -this.creator.getHeight(); currentY = -this.creator.getHeight();
} }
public String getXCreatorName(FormDesigner designer, XCreator x) { public String getXCreatorName(FormDesigner designer, XCreator x) {
String def = x.createDefaultName(); String def = x.createDefaultName();
if (x.acceptType(XWParameterLayout.class)) { if (x.acceptType(XWParameterLayout.class)) {
@ -75,17 +75,17 @@ public class AddingModel {
} }
return def + i; return def + i;
} }
public int getCurrentX() { public int getCurrentX() {
return currentX; return currentX;
} }
public int getCurrentY() { public int getCurrentY() {
return currentY; return currentY;
} }
/** /**
* 移动组件图标到鼠标事件发生的位置 * 移动组件图标到鼠标事件发生的位置
* *
@ -101,6 +101,10 @@ public class AddingModel {
return this.creator; return this.creator;
} }
public boolean need2paint(){
return currentX + this.creator.getWidth() > 0 && currentY + this.creator.getHeight() > 0;
}
/** /**
* 当前组件是否已经添加到某个容器中 * 当前组件是否已经添加到某个容器中
* *
@ -138,4 +142,4 @@ public class AddingModel {
y + designer.getArea().getVerticalValue() - rect.y); y + designer.getArea().getVerticalValue() - rect.y);
return added; return added;
} }
} }

4
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -452,8 +452,8 @@ public class SelectionModel {
} }
} }
if (hasSelectionComponent()) { if (hasSelectionComponent()) {
int x = e.getX() + designer.getArea().getHorizontalValue(); int x = e.getX() + designer.getHorizontalScaleValue();
int y = e.getY() + designer.getArea().getVerticalValue(); int y = e.getY() + designer.getVerticalScaleValue();
dir = getDirection(selection.getRelativeBounds(), x, y); dir = getDirection(selection.getRelativeBounds(), x, y);
if (selection.size() == 1 && !ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir if (selection.size() == 1 && !ArrayUtils.contains(selection.getSelectedCreator().getDirections(), dir
.getActual())) { .getActual())) {

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() { public void propertyChange() {
FreeButton button = (FreeButton) data; FreeButton button = (FreeButton) data;
if (button.getFont() != null) { if (button.getFont() != null) {
setContentLabelFont(button.getFont().applyResolutionNP( contentLabel.setFont(button.getFont().applyResolutionNP(
FontTransformUtil.getDesignerFontResolution())); FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground()); contentLabel.setForeground(button.getFont().getForeground());
} }
@ -230,7 +230,7 @@ public class XButton extends XWidgetCreator {
if (!button.isCustomStyle()) { if (!button.isCustomStyle()) {
l.setBorder(BorderFactory.createLineBorder(new Color(148, 148, 148))); l.setBorder(BorderFactory.createLineBorder(new Color(148, 148, 148)));
bg = DEFAULTBG; bg = DEFAULTBG;
setContentLabelFont(DEFAULTFT); contentLabel.setFont(DEFAULTFT);
contentLabel.setForeground(DEFAULTFOREGROUNDCOLOR); contentLabel.setForeground(DEFAULTFOREGROUNDCOLOR);
editor.setLayout(new BorderLayout()); editor.setLayout(new BorderLayout());
editor.add(l, BorderLayout.CENTER); editor.add(l, BorderLayout.CENTER);
@ -239,7 +239,7 @@ public class XButton extends XWidgetCreator {
editor.setLayout(new BorderLayout()); editor.setLayout(new BorderLayout());
editor.add(l,BorderLayout.CENTER); editor.add(l,BorderLayout.CENTER);
if (button.getFont() != null) { if (button.getFont() != null) {
setContentLabelFont(button.getFont().applyResolutionNP( contentLabel.setFont(button.getFont().applyResolutionNP(
FontTransformUtil.getDesignerFontResolution())); FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground()); contentLabel.setForeground(button.getFont().getForeground());
} }
@ -302,26 +302,11 @@ public class XButton extends XWidgetCreator {
setButtonText(button.getText()); setButtonText(button.getText());
checkButonType(); checkButonType();
if (button.getFont() != null) { if (button.getFont() != null) {
setContentLabelFont(button.getFont().applyResolutionNP( contentLabel.setFont(button.getFont().applyResolutionNP(
FontTransformUtil.getDesignerFontResolution())); FontTransformUtil.getDesignerFontResolution()));
contentLabel.setForeground(button.getFont().getForeground()); 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,7 +49,6 @@ import java.util.Set;
* *
*/ */
public abstract class XCreator extends JPanel implements XComponent, XCreatorTools { 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); protected static final Border DEFALUTBORDER = BorderFactory.createLineBorder(new Color(210, 210, 210), 1);
public static final Dimension SMALL_PREFERRED_SIZE = new Dimension(80, 21); public static final Dimension SMALL_PREFERRED_SIZE = new Dimension(80, 21);
@ -103,14 +102,6 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
} }
} }
public double getScale() {
return scale;
}
public void setScale(double scale) {
this.scale = scale;
}
/** /**
* 初始化组件大小 * 初始化组件大小
*/ */

8
designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java

@ -311,14 +311,6 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
return new Dimension(this.getWidth(), this.getHeight()); return new Dimension(this.getWidth(), this.getHeight());
} }
public void paint(Graphics g) {
BufferedImage image = toData().getECImage();
if (image != null) {
setLabelBackground(image.getScaledInstance(this.getWidth(), this.getHeight(), Image.SCALE_FAST), imageLable);
}
super.paint(g);
}
/** /**
* 响应点击事件 * 响应点击事件
* @param editingMouseListener 事件处理器 * @param editingMouseListener 事件处理器

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

@ -17,7 +17,6 @@ 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.FRFont;
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;
@ -95,11 +94,8 @@ public class XLabel extends XWidgetCreator {
} }
if (label.getWidgetValue() != null) { if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create(); 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() BaseUtils.drawStringStyleInRotation(g2d, this.getWidth(), this.getHeight(), label.getWidgetValue()
.toString(), Style.getInstance(font.applySize(fontsize)) .toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign())
.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),
FontTransformUtil.getDesignerFontResolution()); FontTransformUtil.getDesignerFontResolution());

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

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

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

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

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

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

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

@ -30,8 +30,6 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.WLayout; 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.FRScreen;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
@ -399,7 +397,6 @@ public class XWAbsoluteLayout extends XLayoutContainer {
return; return;
} }
XWidgetCreator creator = (XWidgetCreator) e.getChild(); XWidgetCreator creator = (XWidgetCreator) e.getChild();
creator.setScale(this.getScale());
WAbsoluteLayout wabs = this.toData(); WAbsoluteLayout wabs = this.toData();
if (!creator.acceptType(XWFitLayout.class)) { if (!creator.acceptType(XWFitLayout.class)) {
creator.setDirections(Direction.ALL); creator.setDirections(Direction.ALL);
@ -605,17 +602,4 @@ public class XWAbsoluteLayout extends XLayoutContainer {
return super.getWidgetPropertyUIProviders(); 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(); WBorderLayout wlayout = this.toData();
Object constraints = wlayout.getConstraints(wgt); Object constraints = wlayout.getConstraints(wgt);
Dimension d = new Dimension(); Dimension d = new Dimension();
if (ComparatorUtils.equals(WBorderLayout.NORTH, constraints)) { if (ComparatorUtils.equals(WBorderLayout.NORTH,constraints)) {
d.height = (int) (wlayout.getNorthSize() * getScale()); d.height = wlayout.getNorthSize();
} else if (ComparatorUtils.equals(WBorderLayout.SOUTH, constraints)) { } else if (ComparatorUtils.equals(WBorderLayout.SOUTH,constraints)) {
d.height = (int) (wlayout.getSouthSize() * getScale()); d.height = wlayout.getSouthSize();
} else if (ComparatorUtils.equals(WBorderLayout.EAST, constraints)) { } else if (ComparatorUtils.equals(WBorderLayout.EAST,constraints)) {
d.width = (int) (wlayout.getEastSize() * getScale()); d.width = wlayout.getEastSize();
} else if (ComparatorUtils.equals(WBorderLayout.WEST, constraints)) { } else if (ComparatorUtils.equals(WBorderLayout.WEST,constraints)) {
d.width = (int) (wlayout.getWestSize() * getScale()); d.width = wlayout.getWestSize();
} }
return d; return d;
} }
@ -203,40 +203,8 @@ public class XWBorderLayout extends XLayoutContainer {
} }
} }
@Override @Override
public LayoutAdapter getLayoutAdapter() { public LayoutAdapter getLayoutAdapter() {
return new FRBorderLayoutAdapter(this); 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));
}
}
}
} }

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

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

1
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XCardAddButton.java

@ -166,7 +166,6 @@ public class XCardAddButton extends XButton {
XCardSwitchButton showButton = new XCardSwitchButton(titleButton, dimension, cardLayout, tagLayout); XCardSwitchButton showButton = new XCardSwitchButton(titleButton, dimension, cardLayout, tagLayout);
titleButton.setShowButton(true); titleButton.setShowButton(true);
showButton.setBackupParent(tagLayout); showButton.setBackupParent(tagLayout);
showButton.setScale(this.getScale());
this.tagLayout.setCurrentCard(titleButton); this.tagLayout.setCurrentCard(titleButton);
this.tagLayout.setTabFitIndex(index); this.tagLayout.setTabFitIndex(index);
this.tagLayout.add(showButton); this.tagLayout.add(showButton);

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

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

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

@ -137,7 +137,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard); WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard);
fitLayout.setTabNameIndex(getTabNameIndex()); fitLayout.setTabNameIndex(getTabNameIndex());
XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension()); XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension());
tabFitLayout.setScale(this.getScale());
WCardTagLayout layout = (WCardTagLayout) this.toData(); WCardTagLayout layout = (WCardTagLayout) this.toData();
if(!ComparatorUtils.equals(layout.getTemplateStyle().getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE)){ if(!ComparatorUtils.equals(layout.getTemplateStyle().getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE)){
@ -291,6 +290,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
@Override @Override
public void doLayout() { public void doLayout() {
setTabsAndAdjust();
//设置布局 //设置布局
super.doLayout(); super.doLayout();
} }
@ -357,7 +357,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
BorderPacker borderStyle = this.cardLayout.toData().getBorderStyle(); BorderPacker borderStyle = this.cardLayout.toData().getBorderStyle();
FRFont f = borderStyle.getTitle().getFrFont(); FRFont f = borderStyle.getTitle().getFrFont();
FontMetrics fm = GraphHelper.getFontMetrics(f); FontMetrics fm = GraphHelper.getFontMetrics(f);
double scale = this.getScale();
switch (wCardTagLayout.getTextDirection()) { switch (wCardTagLayout.getTextDirection()) {
case TEXT_HORI_DERECTION: case TEXT_HORI_DERECTION:
@ -383,6 +382,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} else { } else {
adjustTabsV(parent, tabLength, cardWidth, cardHeight); adjustTabsV(parent, tabLength, cardWidth, cardHeight);
} }
fixTitleLayout(parent);
} }
public void adjustTabsH(XLayoutContainer parent, int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) { public void adjustTabsH(XLayoutContainer parent, int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
@ -394,8 +394,8 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
int tempX = 0; int tempX = 0;
for (int i = 0; i < tabLength; i++) { for (int i = 0; i < tabLength; i++) {
Rectangle rectangle = this.getComponent(i).getBounds(); Rectangle rectangle = this.getComponent(i).getBounds();
int cardWidth = (int) ((width.get(i) + WIDTH_SIDE_OFFSET) * this.getScale()); Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET;
int cardHeight = tabPaneSize; Integer cardHeight = tabPaneSize;
rectangle.setBounds(tempX, 0, cardWidth, cardHeight); rectangle.setBounds(tempX, 0, cardWidth, cardHeight);
tempX += cardWidth; tempX += cardWidth;
XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i);
@ -446,8 +446,4 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
} }
} }
public void adjustCompSize(double percent){
setTabsAndAdjust();
}
} }

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

@ -8,11 +8,15 @@ import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWFitLayout; 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.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormHierarchyTreePane; 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.ButtonTypeEditor;
import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor; import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
@ -357,7 +361,14 @@ public class XWTabFitLayout extends XWFitLayout {
return parent == null ? null : parent.findNearestFit(); return parent == null ? null : parent.findNearestFit();
} }
/**
* 非顶层自适应布局的缩放
* @param percent 百分比
*/
@Override
public void adjustCompSize(double percent) {
this.adjustCreatorsWhileSlide(percent);
}
/** /**
* 该布局需要隐藏无需对边框进行操作 * 该布局需要隐藏无需对边框进行操作

11
designer-form/src/main/java/com/fr/design/form/layout/FRFitLayout.java

@ -8,7 +8,6 @@ import java.awt.LayoutManager;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import com.fr.design.designer.creator.XCreator;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
public class FRFitLayout implements FRLayoutManager, LayoutManager{ public class FRFitLayout implements FRLayoutManager, LayoutManager{
@ -76,9 +75,6 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
public void layoutContainer(Container target) { public void layoutContainer(Container target) {
synchronized (target.getTreeLock()) { synchronized (target.getTreeLock()) {
Insets insets = target.getInsets(); Insets insets = target.getInsets();
XCreator creator = (XCreator) target;
double scale = creator.getScale();
processMarginScale(insets, scale);
int width = target.getWidth(); int width = target.getWidth();
int height = target.getHeight(); int height = target.getHeight();
calculateLastInset(target, width, height); calculateLastInset(target, width, height);
@ -109,13 +105,6 @@ public class FRFitLayout implements FRLayoutManager, LayoutManager{
} }
} }
private void processMarginScale(Insets insets, double scale ){
insets.top *= scale;
insets.left *= scale;
insets.right *= scale;
insets.bottom *= scale;
}
private void calculateLastInset(Container target, int width, int height) { private void calculateLastInset(Container target, int width, int height) {
int len = target.getComponentCount(); int len = target.getComponentCount();
if (len ==0) { if (len ==0) {

6
designer-form/src/main/java/com/fr/design/form/layout/FRTitleLayout.java

@ -8,7 +8,6 @@ import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.LayoutManager; import java.awt.LayoutManager;
import com.fr.design.designer.creator.XCreator;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.WTitleLayout;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -121,16 +120,15 @@ public class FRTitleLayout implements FRLayoutManager, LayoutManager{
*/ */
@Override @Override
public void layoutContainer(Container target) { public void layoutContainer(Container target) {
double scale = ((XCreator)target).getScale();
synchronized (target.getTreeLock()) { synchronized (target.getTreeLock()) {
int width = target.getWidth(); int width = target.getWidth();
int height = target.getHeight(); int height = target.getHeight();
int titleH = title == null ? 0 : (int) (WTitleLayout.TITLE_HEIGHT * scale); int titleH = title==null ? 0 : WTitleLayout.TITLE_HEIGHT;
for (int i=0; i< target.getComponentCount(); i++) { for (int i=0; i< target.getComponentCount(); i++) {
Component comp = target.getComponent(i); Component comp = target.getComponent(i);
if (comp != null) { if (comp != null) {
if (comp == title) { if (comp == title) {
comp.setBounds(0, 0, width, titleH); comp.setBounds(0, 0, width, WTitleLayout.TITLE_HEIGHT);
} else if (comp == body) { } else if (comp == body) {
int y = titleH + gap; int y = titleH + gap;
comp.setBounds(0, y, width, height-y); comp.setBounds(0, y, width, height-y);

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

@ -139,6 +139,9 @@ public class EditingMouseListener extends MouseInputAdapter {
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
int oldX = e.getX();
int oldY = e.getY();
offsetEventPoint(e);
if (!stopEditing()) { if (!stopEditing()) {
return; return;
} }
@ -171,6 +174,13 @@ public class EditingMouseListener extends MouseInputAdapter {
stateModel.startResizing(e); stateModel.startResizing(e);
} }
} }
e.translatePoint(oldX - e.getX(), oldY - e.getY());
}
private void offsetEventPoint(MouseEvent e){
int x = designer.getRelativeX(e.getX());
int y = designer.getRelativeY(e.getY());
e.translatePoint(x - e.getX(), y - e.getY());
} }
/** /**
@ -179,6 +189,9 @@ public class EditingMouseListener extends MouseInputAdapter {
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
int oldX = e.getX();
int oldY = e.getY();
offsetEventPoint(e);
if (e.isPopupTrigger()) { if (e.isPopupTrigger()) {
if (stateModel.isDragging()) { if (stateModel.isDragging()) {
stateModel.draggingCancel(); stateModel.draggingCancel();
@ -199,6 +212,7 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
lastPressEvent = null; lastPressEvent = null;
lastXCreator = null; lastXCreator = null;
e.translatePoint(oldX - e.getX(), oldY - e.getY());
} }
private void mouseDraggingRelease(MouseEvent e) { private void mouseDraggingRelease(MouseEvent e) {
@ -261,6 +275,9 @@ public class EditingMouseListener extends MouseInputAdapter {
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
int oldX = e.getX();
int oldY = e.getY();
offsetEventPoint(e);
XCreator component = designer.getComponentAt(e); XCreator component = designer.getComponentAt(e);
setCoverPaneNotDisplay(component, e, false); setCoverPaneNotDisplay(component, e, false);
@ -299,8 +316,9 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
processChartEditorMouseMove(component, e); processChartEditorMouseMove(component, e);
e.translatePoint(oldX - e.getX(), oldY - e.getY());
designer.repaint(); designer.repaint();
} }
private void elementCaseMouseMoved(MouseEvent e, XCreator component) { private void elementCaseMouseMoved(MouseEvent e, XCreator component) {
@ -436,6 +454,9 @@ public class EditingMouseListener extends MouseInputAdapter {
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
int oldX = e.getX();
int oldY = e.getY();
offsetEventPoint(e);
if (DesignerMode.isAuthorityEditing()) { if (DesignerMode.isAuthorityEditing()) {
return; return;
} }
@ -485,6 +506,7 @@ public class EditingMouseListener extends MouseInputAdapter {
lastPressEvent = null; lastPressEvent = null;
} }
} }
e.translatePoint(oldX - e.getX(), oldY - e.getY());
designer.repaint(); designer.repaint();
} }
@ -556,6 +578,9 @@ public class EditingMouseListener extends MouseInputAdapter {
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int oldX = e.getX();
int oldY = e.getY();
offsetEventPoint(e);
XCreator creator = designer.getComponentAt(e); XCreator creator = designer.getComponentAt(e);
boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3; boolean isValidButton = e.getButton() == MouseEvent.BUTTON1 || e.getButton() == MouseEvent.BUTTON3;
@ -575,6 +600,7 @@ public class EditingMouseListener extends MouseInputAdapter {
} }
creator.doLayout(); creator.doLayout();
} }
e.translatePoint(oldX - e.getX(), oldY - e.getY());
LayoutUtils.layoutRootContainer(designer.getRootComponent()); LayoutUtils.layoutRootContainer(designer.getRootComponent());
} }
@ -585,10 +611,14 @@ public class EditingMouseListener extends MouseInputAdapter {
* @param e 鼠标事件 * @param e 鼠标事件
*/ */
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
int oldX = e.getX();
int oldY = e.getY();
offsetEventPoint(e);
if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR && !(e.isShiftDown() || InputEventBaseOnOS.isControlDown(e))) { if (designer.getCursor().getType() != Cursor.DEFAULT_CURSOR && !(e.isShiftDown() || InputEventBaseOnOS.isControlDown(e))) {
designer.setCursor(Cursor.getDefaultCursor()); designer.setCursor(Cursor.getDefaultCursor());
} }
cancelPromptWidgetForbidEnter(); cancelPromptWidgetForbidEnter();
e.translatePoint(oldX - e.getX(), oldY - e.getY());
} }
/** /**

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

@ -228,11 +228,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
}; };
private void scale(int value){ private void scale(int value){
this.designer.setResolution(value); this.designer.setScale(value / DEFAULT_SLIDER);
this.designer.getArea().resolution = value; FormArea.this.validate();
reCalculateRoot(value, true); this.designer.repaint();
} }
/** /**
* 返回当前的屏幕分辨率对应的百分比值 * 返回当前的屏幕分辨率对应的百分比值
* *
@ -446,10 +447,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
if (root.acceptType(XWFitLayout.class)) { if (root.acceptType(XWFitLayout.class)) {
XWFitLayout layout = (XWFitLayout) root; XWFitLayout layout = (XWFitLayout) root;
Dimension dimension = layout.getSize(); Dimension dimension = layout.getSize();
double widthScale = dim.width / (double) dimension.width; // double widthScale = dim.width / (double) dimension.width;
double heightScale = dim.height / (double) dimension.height; // double heightScale = dim.height / (double) dimension.height;
final double scaleValue = Math.min(widthScale, heightScale); // final double scaleValue = Math.min(widthScale, heightScale);
int value = (int) (scaleValue * 100); int value = 100;
slidePane.setShowValue(value); slidePane.setShowValue(value);
if (value == 100) { if (value == 100) {
return; return;
@ -569,9 +570,9 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
layout(); layout();
if (isValid) { if (isValid) {
XLayoutContainer root = designer.getRootComponent(); XLayoutContainer root = designer.getRootComponent();
setScrollBarProperties(root.getWidth() - designer.getWidth(), horScrollBar, horizontalValue); setScrollBarProperties((int) (root.getWidth()*designer.getScale() - designer.getWidth()), horScrollBar, horizontalValue);
//计算滚动条值的时候应该算上参数面板的高度 //计算滚动条值的时候应该算上参数面板的高度
setScrollBarProperties(designer.getParaHeight() + root.getHeight() - designer.getHeight(), verScrollBar, verticalValue); setScrollBarProperties((int) (designer.getParaHeight() + root.getHeight()*designer.getScale() - designer.getHeight()), verScrollBar, verticalValue);
} }
} }
@ -775,7 +776,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
layout.moveContainerMargin(); layout.moveContainerMargin();
layout.addCompInterval(layout.getAcualInterval()); layout.addCompInterval(layout.getAcualInterval());
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) {
reCalculateRoot(slide, true); // reCalculateRoot(slide, true);
} }
this.slidePane.setShowValue((int) slide); this.slidePane.setShowValue((int) slide);
} }
@ -785,7 +786,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
@Override @Override
public void fireCreatorModified(DesignerEvent evt) { public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED|| evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { if (evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED|| evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) {
FormArea.this.reCalculateRoot(slidePane.getShowValue(), true); // FormArea.this.reCalculateRoot(slidePane.getShowValue(), true);
} }
} }
}; };
@ -860,6 +861,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
int maxWidth = right - vbarPreferredSize.width; int maxWidth = right - vbarPreferredSize.width;
DESIGNERWIDTH = DESIGNERWIDTH > maxWidth ? maxWidth : DESIGNERWIDTH; DESIGNERWIDTH = DESIGNERWIDTH > maxWidth ? maxWidth : DESIGNERWIDTH;
DESIGNERHEIGHT = DESIGNERHEIGHT > maxHeight ? maxHeight : DESIGNERHEIGHT; DESIGNERHEIGHT = DESIGNERHEIGHT > maxHeight ? maxHeight : DESIGNERHEIGHT;
DESIGNERWIDTH = maxWidth;
DESIGNERHEIGHT = maxHeight;
int designerLeft = left + (verScrollBar.getX() - DESIGNERWIDTH) / 2; int designerLeft = left + (verScrollBar.getX() - DESIGNERWIDTH) / 2;
int designerTop = top + (horScrollBar.getY() - DESIGNERHEIGHT) / 2; int designerTop = top + (horScrollBar.getY() - DESIGNERHEIGHT) / 2;
rec = new Rectangle(designerLeft, designerTop, DESIGNERWIDTH, DESIGNERHEIGHT); rec = new Rectangle(designerLeft, designerTop, DESIGNERWIDTH, DESIGNERHEIGHT);

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

@ -240,7 +240,7 @@ public class FormCreatorDropTarget extends DropTarget {
@Override @Override
public synchronized void dragEnter(DropTargetDragEvent dtde) { public synchronized void dragEnter(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
this.entering(loc.x, loc.y); this.entering(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y));
} }
/** /**
@ -251,7 +251,7 @@ public class FormCreatorDropTarget extends DropTarget {
@Override @Override
public synchronized void dragOver(DropTargetDragEvent dtde) { public synchronized void dragOver(DropTargetDragEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
hovering(loc.x, loc.y); hovering(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y));
} }
/** /**
@ -282,7 +282,7 @@ public class FormCreatorDropTarget extends DropTarget {
@Override @Override
public synchronized void drop(DropTargetDropEvent dtde) { public synchronized void drop(DropTargetDropEvent dtde) {
Point loc = dtde.getLocation(); Point loc = dtde.getLocation();
this.adding(loc.x, loc.y); this.adding(designer.getRelativeX(loc.x), designer.getRelativeY(loc.y));
//针对在表单中拖入一个控件直接ctrl+s无反应 //针对在表单中拖入一个控件直接ctrl+s无反应
designer.requestFocus(); designer.requestFocus();
} }

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

@ -103,6 +103,9 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
protected static final ArrayList<String> NAME_ARRAY_LIST = new ArrayList<String>( protected static final ArrayList<String> NAME_ARRAY_LIST = new ArrayList<String>(
Arrays.asList(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Copy"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Edit_Delete")}) Arrays.asList(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Copy"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Edit_Delete")})
); );
private double scale = 1.0D;
//底层容器的默认大小 //底层容器的默认大小
protected static final Dimension LARGE_PREFERRED_SIZE = new Dimension(WBorderLayout.DEFAULT_WIDTH, WBorderLayout.DEFAULT_HEIGHT); protected static final Dimension LARGE_PREFERRED_SIZE = new Dimension(WBorderLayout.DEFAULT_WIDTH, WBorderLayout.DEFAULT_HEIGHT);
private int paraHeight = 0; private int paraHeight = 0;
@ -448,21 +451,15 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
if (paraComponent != null) { if (paraComponent != null) {
return; return;
} }
paraHeight = WBorderLayout.DEFAULT_SIZE;
paraComponent = new XWParameterLayout(); paraComponent = new XWParameterLayout();
paraComponent.toData().setWidgetName("para"); paraComponent.toData().setWidgetName("para");
paraComponent.setSize(paraComponent.initEditorSize()); paraComponent.setSize(paraComponent.initEditorSize());
paraComponent.setScale(rootComponent.getScale());
this.setParaHeight(WBorderLayout.DEFAULT_SIZE);
paraComponent.setPreferredSize(new Dimension(paraComponent.getSize().width, this.getParaHeight()));
XWBorderLayout formLayoutContainer = (XWBorderLayout) rootComponent.getParent(); XWBorderLayout formLayoutContainer = (XWBorderLayout) rootComponent.getParent();
//设下northSize,增加para后,重置border大小,这时候para和root的大小会自适应调整 formLayoutContainer.toData().setNorthSize(paraHeight);
formLayoutContainer.add(paraComponent, WBorderLayout.NORTH); formLayoutContainer.add(paraComponent, WBorderLayout.NORTH);
//设下northSize,增加para后,重置border大小,这时候para和root的大小会自适应调整
formLayoutContainer.setSize(formLayoutContainer.getWidth(), formLayoutContainer.getHeight() + paraHeight);
selectionModel.reset(); selectionModel.reset();
selectionModel.setSelectedCreator(paraComponent); selectionModel.setSelectedCreator(paraComponent);
invalidateLayout(); invalidateLayout();
@ -499,12 +496,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
public void setParaHeight(int height) { public void setParaHeight(int height) {
XWBorderLayout container = (XWBorderLayout) getTopContainer(); XWBorderLayout container = (XWBorderLayout) getTopContainer();
container.toData().setNorthSize(height); container.toData().setNorthSize(height);
int displayHeight = (int) (height * container.getScale()); container.setSize(container.getWidth(), container.getHeight() + height - getParaHeight());
container.setSize(container.getWidth(), container.getHeight() + displayHeight - getParaHeight()); paraHeight = height;
paraHeight = displayHeight;
} }
/** /**
* 删除参数界面 * 删除参数界面
*/ */
@ -992,8 +989,8 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
@Nullable @Nullable
public XCreator getComponentAt(int x, int y, XCreator[] except) { public XCreator getComponentAt(int x, int y, XCreator[] except) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent; XLayoutContainer container = y + this.getPaintY() < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent;
XCreator comp = xCreatorAt(x + formArea.getHorizontalValue(), y + formArea.getVerticalValue(), container, XCreator comp = xCreatorAt(x + (int)(formArea.getHorizontalValue()/scale), (int)(y + formArea.getVerticalValue()/scale), container,
except); except);
return comp == null ? container : comp; return comp == null ? container : comp;
} }
@ -1556,4 +1553,48 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
public int getResolution() { public int getResolution() {
return this.resolution; return this.resolution;
} }
public double getScale() {
return scale;
}
public void setScale(double scale) {
this.scale = scale;
}
public int getPaintX() {
if (this.rootComponent == null || this.rootComponent.getParent() == null) {
return 0;
}
int width = this.rootComponent.getParent().getWidth();
int x = (int) ((this.getWidth() - width * scale) / 2);
return Math.max(x, 0);
}
public int getPaintY() {
if (this.rootComponent == null || this.rootComponent.getParent() == null) {
return 0;
}
int height = this.rootComponent.getParent().getHeight();
int y = (int) ((this.getHeight() - height * scale) / 2);
return Math.max(y, 0);
}
public int getRelativeX(int x) {
return (int) ((x - this.getPaintX()) / this.getScale());
}
public int getRelativeY(int y) {
return (int) ((y - this.getPaintY()) / this.getScale());
}
public int getHorizontalScaleValue() {
return (int) (this.getArea().getHorizontalValue() / this.scale);
}
public int getVerticalScaleValue() {
return (int) (this.getArea().getVerticalValue() / this.scale);
}
} }

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

@ -30,6 +30,7 @@ import java.awt.Component;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.ArrayList; import java.util.ArrayList;
@ -66,7 +67,14 @@ public class FormDesignerUI extends ComponentUI {
@Override @Override
public void paint(final Graphics g, JComponent c) { public void paint(final Graphics g, JComponent c) {
XCreator rootComponent = designer.getRootComponent(); XCreator rootComponent = designer.getRootComponent();
this.time = (float)designer.getResolution()/ScreenResolution.getScreenResolution(); this.time = (float) designer.getResolution() / ScreenResolution.getScreenResolution();
AffineTransform at = new AffineTransform();
if (rootComponent.getParent() != null) {
at.translate(designer.getPaintX(), designer.getPaintY());
at.scale(designer.getScale(), designer.getScale());
Graphics2D g2 = (Graphics2D) g;
g2.transform(at);
}
if (rootComponent != null) { if (rootComponent != null) {
// 设计自适应界面 // 设计自适应界面
repaintFit(g, rootComponent, c); repaintFit(g, rootComponent, c);
@ -189,9 +197,13 @@ public class FormDesignerUI extends ComponentUI {
* 渲染当前正在添加的组件采用Renderer原理 * 渲染当前正在添加的组件采用Renderer原理
*/ */
private void paintAddingBean(Graphics g, final AddingModel addingModel) { private void paintAddingBean(Graphics g, final AddingModel addingModel) {
if (!addingModel.need2paint()) {
return;
}
XCreator bean = addingModel.getXCreator(); XCreator bean = addingModel.getXCreator();
int x = addingModel.getCurrentX(); int x = addingModel.getCurrentX();
int y = addingModel.getCurrentY(); int y = addingModel.getCurrentY();
int width = bean.getWidth(); int width = bean.getWidth();
int height = bean.getHeight(); int height = bean.getHeight();
Graphics clipg = g.create(x, y, width, height); Graphics clipg = g.create(x, y, width, height);
@ -277,17 +289,17 @@ public class FormDesignerUI extends ComponentUI {
designer.getStateModel().paintAbsorptionline(g); designer.getStateModel().paintAbsorptionline(g);
} }
bounds.x -= designer.getArea().getHorizontalValue(); bounds.x -= designer.getHorizontalScaleValue();
bounds.y -= designer.getArea().getVerticalValue(); bounds.y -= designer.getVerticalScaleValue();
drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height); drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height);
//选中时边框颜色 //选中时边框颜色
g.setColor(XCreatorConstants.FORM_BORDER_COLOR); g.setColor(XCreatorConstants.LAYOUT_FORBIDDEN_COLOR);
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) {
Rectangle creatorBounds = ComponentUtils.getRelativeBounds(creator); Rectangle creatorBounds = ComponentUtils.getRelativeBounds(creator);
creatorBounds.x -= designer.getArea().getHorizontalValue(); creatorBounds.x -= designer.getHorizontalScaleValue();
creatorBounds.y -= designer.getArea().getVerticalValue(); creatorBounds.y -= designer.getVerticalScaleValue();
if (creator.acceptType(XWFitLayout.class)) { if (creator.acceptType(XWFitLayout.class)) {
resetFitlayoutBounds(creatorBounds); resetFitlayoutBounds(creatorBounds);
} else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) {
@ -395,17 +407,11 @@ public class FormDesignerUI extends ComponentUI {
ComponentUtils.disableBuffer(component, dbcomponents); ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg; Graphics clipg;
clipg = g.create( clipg = g.create(
-designer.getArea().getHorizontalValue(), -designer.getHorizontalScaleValue(),
-designer.getArea().getVerticalValue() + designer.getParaHeight(), -designer.getVerticalScaleValue() + designer.getParaHeight(),
parent.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().width + designer.getArea().getHorizontalValue(),
parent.getSize().height + designer.getArea().getVerticalValue()); parent.getSize().height + designer.getArea().getVerticalValue());
// BufferedImage img = CoreGraphHelper.createBufferedImage(parent.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().height + designer.getArea().getVerticalValue(), BufferedImage.TYPE_INT_RGB);
// Graphics2D g2d = img.createGraphics();
// component.printAll(g2d);
// g2d.dispose();
// g.drawImage(img,-designer.getArea().getHorizontalValue(),-designer.getArea().getVerticalValue() + designer.getParaHeight(), (int) (parent.getSize().width*time + designer.getArea().getHorizontalValue()), (int) (parent.getSize().height*time + designer.getArea().getVerticalValue()),null);
designer.paintContent(clipg); designer.paintContent(clipg);
paintWatermark((Graphics2D) clipg); paintWatermark((Graphics2D) clipg);
clipg.dispose(); clipg.dispose();
@ -427,8 +433,8 @@ public class FormDesignerUI extends ComponentUI {
// 禁止双缓冲 // 禁止双缓冲
ComponentUtils.disableBuffer(component, dbcomponents); ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg1; Graphics clipg1;
clipg1 = g.create(-designer.getArea().getHorizontalValue(), clipg1 = g.create(-designer.getHorizontalScaleValue(),
-designer.getArea().getVerticalValue() , -designer.getVerticalScaleValue(),
parent.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().width + designer.getArea().getHorizontalValue(),
designer.getParaHeight() + designer.getArea().getVerticalValue()); designer.getParaHeight() + designer.getArea().getVerticalValue());

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

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

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

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

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

@ -20,8 +20,9 @@ import com.fr.design.widget.WidgetBoundsPaneFactory;
import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.PaddingMargin;
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.form.ui.widget.CRBoundsWidget;
import javax.swing.JOptionPane;
import java.awt.Rectangle; import java.awt.Rectangle;
@ -45,8 +46,8 @@ public class WidgetBoundPane extends BasicPane {
} }
public XLayoutContainer getParent(XCreator source) { public XLayoutContainer getParent(XCreator source) {
if (source.acceptType(XWCardTagLayout.class)) { if(source.acceptType(XWCardTagLayout.class)){
return (XLayoutContainer) source.getParent(); return (XLayoutContainer)source.getParent();
} }
XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source);
if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) {
@ -78,28 +79,18 @@ public class WidgetBoundPane extends BasicPane {
} }
public void populate() { public void populate() {
WLayout wabs = parent.toData(); Rectangle bounds = new Rectangle(creator.getBounds());
CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData());
if (boundsWidget == null){
return;
}
Rectangle bounds = new Rectangle(boundsWidget.getBounds());
width.setValue(bounds.width); width.setValue(bounds.width);
height.setValue(bounds.height); height.setValue(bounds.height);
} }
public void fix() { public void fix() {
WLayout wabs = parent.toData(); Rectangle bounds = new Rectangle(creator.getBounds());
CRBoundsWidget boundsWidget = wabs.getBoundsWidget(creator.toData());
if (boundsWidget == null){
return;
}
Rectangle bounds = new Rectangle(boundsWidget.getBounds());
creator.setBackupBound(creator.getBounds()); creator.setBackupBound(creator.getBounds());
int w = (int) width.getValue(); int w = (int) width.getValue();
int h = (int) height.getValue(); int h = (int) height.getValue();
Rectangle rec = ComponentUtils.getRelativeBounds(parent); Rectangle rec = ComponentUtils.getRelativeBounds(parent);
WLayout wabs = parent.toData();
if (bounds.width != w) { if (bounds.width != w) {
limitWidth(wabs, w, bounds, rec); limitWidth(wabs, w, bounds, rec);
} }
@ -120,61 +111,45 @@ public class WidgetBoundPane extends BasicPane {
} }
public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) { public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) {
int scaleDiff = 0; int difference = 0;
double scale = parent.getScale();
int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling()); int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling());
PaddingMargin margin = wabs.getMargin(); PaddingMargin margin = wabs.getMargin();
if (bounds.width != w) { if (bounds.width != w) {
if ((int) (bounds.width * scale) == 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, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds"));
width.setValue(bounds.width); width.setValue(bounds.width);
return; return;
} else if (w * scale < 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, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Width") + Integer.toString(minWidth));
width.setValue(bounds.width); width.setValue(bounds.width);
return; return;
} }
int difference = bounds.width - w; difference = bounds.width - w;
scaleDiff = roundValue(difference * scale);
bounds.width = w; bounds.width = w;
} }
Rectangle backupBounds = getBound();
Rectangle newBounds = new Rectangle(backupBounds.x, backupBounds.y, backupBounds.width - scaleDiff, backupBounds.height);
wabs.setBounds(creator.toData(), bounds); wabs.setBounds(creator.toData(), bounds);
adjustComponents(newBounds, scaleDiff, 0); adjustComponents(bounds, difference, 0);
}
private int roundValue(double value) {
if (value < 0) {
return (int) Math.floor(value);
} else {
return (int) Math.ceil(value);
}
} }
public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) { public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) {
double scale = parent.getScale(); int difference = 0;
int scaleDiff = 0;
PaddingMargin margin = wabs.getMargin(); PaddingMargin margin = wabs.getMargin();
int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling()); int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling());
if (bounds.height != h) { if (bounds.height != h) {
if ((int) (bounds.height * scale) == 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, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds"));
height.setValue(bounds.height); height.setValue(bounds.height);
return; return;
} else if (h * scale < 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, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Height") + Integer.toString(minHeight));
height.setValue(bounds.height); height.setValue(bounds.height);
return; return;
} }
int difference = bounds.height - h; difference = bounds.height - h;
scaleDiff = roundValue(difference * scale);
bounds.height = h; bounds.height = h;
} }
Rectangle backupBounds = getBound();
Rectangle newBounds = new Rectangle(backupBounds.x, backupBounds.y, backupBounds.width, backupBounds.height - scaleDiff);
wabs.setBounds(creator.toData(), bounds); wabs.setBounds(creator.toData(), bounds);
adjustComponents(newBounds, scaleDiff, 1); adjustComponents(bounds, difference, 1);
} }

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

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

Loading…
Cancel
Save