@ -7,7 +7,6 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer ;
import com.fr.design.designer.creator.XWBorderLayout ;
import com.fr.design.designer.creator.XWFitLayout ;
import com.fr.design.fit.DesignerUIModeConfig ;
import com.fr.design.gui.ibutton.UIButton ;
import com.fr.design.gui.ibutton.UIButtonUI ;
import com.fr.design.gui.ilable.UILabel ;
@ -25,11 +24,11 @@ import com.fr.design.scrollruler.VerticalRuler;
import com.fr.design.utils.ComponentUtils ;
import com.fr.design.utils.gui.GUIPaintUtils ;
import com.fr.design.utils.gui.LayoutUtils ;
import com.fr.form.fit.NewFormMarkAttr ;
import com.fr.form.main.mobile.FormMobileAttr ;
import com.fr.form.ui.container.WBodyLayoutType ;
import com.fr.form.ui.container.WBorderLayout ;
import com.fr.form.ui.container.WFitLayout ;
import com.fr.general.FRScreen ;
import com.fr.general.IOUtils ;
import com.fr.stable.AssistUtils ;
@ -66,12 +65,10 @@ import java.awt.event.MouseWheelEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER ;
public class FormArea extends JComponent implements ScrollRulerComponent {
private static final double SLIDER_FLOAT = 400 . 0 ;
private static final double SLIDER_MIN = 10 . 0 ;
private static final String SCALE_PLUS_COMMAND = "scale_plus" ;
private static final String SCALE_MINUS_COMMAND = "scale_minus" ;
public static final String FIX_LAYOUT_SWITCH_BUTTON = "fix_layout_switch_button" ;
public static final double DEFAULT_SLIDER = 100 . 0 ;
public static final double DEFAULT_SLIDER = 100 . 0D ;
private static final int ROTATIONS = 50 ;
public static final int SHOWVALMAX = 400 ;
public static final int SHOWVALMIN = 10 ;
@ -90,21 +87,9 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private UINumberField heightPane ;
private JFormSliderPane slidePane ;
private boolean isValid = true ;
// 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER ;
private double screenValue ;
private UIButton fixLayoutSwitchButton ;
private boolean isFixLayoutEditState ;
public FormScrollBar getHorScrollBar ( ) {
return horScrollBar ;
}
public void setHorScrollBar ( FormScrollBar horScrollBar ) {
this . horScrollBar = horScrollBar ;
}
public FormArea ( FormDesigner designer ) {
this ( designer , true ) ;
}
@ -243,7 +228,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
heightPane . setPreferredSize ( new Dimension ( 60 , 0 ) ) ;
slidePane = JFormSliderPane . getInstance ( ) ;
JPanel resizePane = TableLayoutHelper . createCommonTableLayoutPane (
new JComponent [ ] [ ] { { tipsPane , layoutSwitchPane , widthPane ,
new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Indent_Pixel" ) ) ,
@ -258,6 +242,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
slidePane . setVisible ( true ) ;
initCalculateSize ( ) ;
slidePane . addValueChangeListener ( showValSpinnerChangeListener ) ;
slidePane . setShowValue ( FRScreen . getFRScreenByDimension ( Toolkit . getDefaultToolkit ( ) . getScreenSize ( ) ) . getValue ( ) . intValue ( ) ) ;
}
public void undoFixLayoutState ( boolean isFixLayout ) {
@ -309,41 +294,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
this . designer . repaint ( ) ;
}
/ * *
* 返回当前的屏幕分辨率对应的百分比值
*
* @return 缩放的百分比值
* /
public double getScreenValue ( ) {
return screenValue ;
}
/ * *
* 设置屏幕分辨率对应的百分比值
*
* @param screenValue 百分比值
* /
public void setScreenValue ( double screenValue ) {
this . screenValue = screenValue ;
}
private void initCalculateSize ( ) {
Toolkit toolkit = Toolkit . getDefaultToolkit ( ) ;
Dimension scrnsize = toolkit . getScreenSize ( ) ;
this . screenValue = DesignerUIModeConfig . getInstance ( ) . getDesignScreenByDimension ( scrnsize ) . getValue ( ) ;
XLayoutContainer root = FormArea . this . designer . getRootComponent ( ) ;
// 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整
// slidePane.populateBean(screenValue);
if ( root . acceptType ( XWFitLayout . class ) ) {
XWFitLayout layout = ( XWFitLayout ) root ;
if ( ! AssistUtils . equals ( screenValue , DEFAULT_SLIDER ) ) {
reCalculateRoot ( screenValue , true ) ;
} else {
// 组件间隔啊
// REPORT-2585 原有的逻辑导致嵌套的tab中的间隔加不上去,会在后续拖动的过程中出问题
reCalculateDefaultRoot ( screenValue , true ) ;
}
reCalculateDefaultRoot ( ) ;
}
LayoutUtils . layoutContainer ( root ) ;
updateCreatorsBackupBound ( root ) ;
@ -380,18 +334,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
// 失去焦点时,可以认为输入结束
int width = ( int ) ( ( UINumberField ) e . getSource ( ) ) . getValue ( ) ;
changeWidthPaneValue ( width ) ;
changeFormMarkAttrWidth ( width ) ;
}
} ) ;
}
private void changeFormMarkAttrWidth ( int width ) {
NewFormMarkAttr newFormMarkAttr = designer . getTarget ( ) . getAttrMark ( NewFormMarkAttr . XML_TAG ) ;
if ( newFormMarkAttr ! = null ) {
newFormMarkAttr . setBodyWidth ( width ) ;
}
}
private void changeWidthPaneValue ( int width ) {
XWFitLayout layout = ( XWFitLayout ) designer . getRootComponent ( ) ;
@ -407,7 +353,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
public void actionPerformed ( ActionEvent evt ) {
int height = ( int ) ( ( UINumberField ) evt . getSource ( ) ) . getValue ( ) ;
changeHeightPaneValue ( height ) ;
changeFormMarkAttrHeight ( height ) ;
}
} ) ;
heightPane . addFocusListener (
@ -420,13 +365,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
} ) ;
}
private void changeFormMarkAttrHeight ( int height ) {
NewFormMarkAttr newFormMarkAttr = designer . getTarget ( ) . getAttrMark ( NewFormMarkAttr . XML_TAG ) ;
if ( newFormMarkAttr ! = null ) {
newFormMarkAttr . setBodyHeight ( height ) ;
}
}
private void changeHeightPaneValue ( int height ) {
XWFitLayout layout = ( XWFitLayout ) designer . getRootComponent ( ) ;
@ -497,78 +435,26 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
* 修改大小后 , 再根据屏幕分辨率调整下
* /
public void doReCalculateRoot ( int width , int height , XWFitLayout layout ) {
// double value = slidePane.updateBean();
//重置滑块的值为默认值100
START_VALUE = DEFAULT_SLIDER ;
if ( AssistUtils . equals ( screenValue , DEFAULT_SLIDER ) ) {
layout . getParent ( ) . setSize ( width , height + designer . getParaHeight ( ) ) ;
FormArea . this . validate ( ) ;
} else {
layout . setBackupGap ( screenValue / DEFAULT_SLIDER ) ;
reCalculateRoot ( screenValue , false ) ;
}
}
/ * *
* 按照界面大小的百分比值调整root大小
*
* @param needCalculateParaHeight 是否需要调整参数界面高度
* @param value
* /
private void reCalculateRoot ( double value , boolean needCalculateParaHeight ) {
if ( AssistUtils . equals ( value , START_VALUE ) ) {
return ;
}
double percent = ( value - START_VALUE ) / START_VALUE ;
XLayoutContainer root = FormArea . this . designer . getRootComponent ( ) ;
if ( root . acceptType ( XWFitLayout . class ) ) {
XWFitLayout layout = ( XWFitLayout ) root ;
layout . setContainerPercent ( value / DEFAULT_SLIDER ) ;
traverAndAdjust ( layout , percent ) ;
layout . adjustCreatorsWhileSlide ( percent ) ;
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
Dimension d = new Dimension ( layout . getWidth ( ) , layout . getHeight ( ) ) ;
// 自适应布局的父层是border
if ( layout . getParent ( ) ! = null ) {
int paraHeight = designer . getParaHeight ( ) ;
if ( needCalculateParaHeight & & paraHeight > 0 ) {
designer . setParaHeight ( paraHeight ) ;
XWBorderLayout parent = ( XWBorderLayout ) layout . getParent ( ) ;
parent . toData ( ) . setNorthSize ( paraHeight ) ;
parent . removeAll ( ) ;
parent . add ( designer . getParaComponent ( ) , WBorderLayout . NORTH ) ;
parent . add ( designer . getRootComponent ( ) , WBorderLayout . CENTER ) ;
}
layout . getParent ( ) . setSize ( d . width , d . height + paraHeight ) ;
// 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea
FormArea . this . validate ( ) ;
}
START_VALUE = value ;
}
layout . getParent ( ) . setSize ( width , height + designer . getParaHeight ( ) ) ;
FormArea . this . validate ( ) ;
}
/ * *
* 按照界面大小的百分比值调整root大小
*
* @param needCalculateParaHeight 是否需要调整参数界面高度
* @param value
* /
private void reCalculateDefaultRoot ( double value , boolean needCalculateParaHeight ) {
private void reCalculateDefaultRoot ( ) {
XLayoutContainer root = FormArea . this . designer . getRootComponent ( ) ;
if ( root . acceptType ( XWFitLayout . class ) ) {
XWFitLayout layout = ( XWFitLayout ) root ;
layout . setContainerPercent ( 1 . 0 ) ;
traverAndAdjust ( layout , 0 . 0 ) ;
layout . adjustCreatorsWhileSlide ( 0 . 0 ) ;
// 拖动滑块,先将内部组件百分比大小计算,再计算容器大小
Dimension d = new Dimension ( layout . getWidth ( ) , layout . getHeight ( ) ) ;
// 自适应布局的父层是border
if ( layout . getParent ( ) ! = null ) {
int paraHeight = designer . getParaHeight ( ) ;
if ( needCalculateParaHeight & & paraHeight > 0 ) {
if ( paraHeight > 0 ) {
designer . setParaHeight ( paraHeight ) ;
XWBorderLayout parent = ( XWBorderLayout ) layout . getParent ( ) ;
parent . toData ( ) . setNorthSize ( paraHeight ) ;
@ -885,16 +771,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
heightPane . setValue ( height ) ;
reCalculateHeight ( ( int ) height ) ;
}
if ( designer . getRootComponent ( ) . acceptType ( XWFitLayout . class ) & & AssistUtils . equals ( screenValue , DEFAULT_SLIDER ) ) {
if ( designer . getRootComponent ( ) . acceptType ( XWFitLayout . class ) ) {
XWFitLayout layout = ( XWFitLayout ) designer . getRootComponent ( ) ;
// 撤销时先refreshRoot了,此处去掉内边距再增加间隔
layout . moveContainerMargin ( ) ;
layout . addCompInterval ( layout . getAcualInterval ( ) ) ;
} else if ( designer . getRootComponent ( ) . acceptType ( XWFitLayout . class ) ) {
START_VALUE = DEFAULT_SLIDER ;
reCalculateRoot ( screenValue , true ) ;
// slidePane.populateBean(slide);
}
this . slidePane . setShowValue ( ( int ) slide ) ;
}