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