@ -4,6 +4,7 @@ import com.fr.design.designer.IntervalConstants;
import com.fr.design.foldablepane.UIExpandablePane ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.ispinner.UISpinner ;
import com.fr.design.i18n.Toolkit ;
import com.fr.design.layout.FRGUIPaneFactory ;
import com.fr.design.layout.TableLayout ;
import com.fr.design.layout.TableLayoutHelper ;
@ -18,6 +19,30 @@ import java.awt.Component;
* Created by plough on 2017 / 8 / 7 .
* /
public class WidgetBoundsPaneFactory {
public enum NameAttribute {
//默认的名称
DEFAULT ( Toolkit . i18nText ( "Fine-Design_Basic_Component_Position" ) , Toolkit . i18nText ( "Fine-Design_Basic_Component_Size" ) ) ,
//控件对应的名称
WIDGET ( Toolkit . i18nText ( "Fine-Design_Basic_Widget_Position" ) , Toolkit . i18nText ( "Fine-Design_Basic_Widget_Size" ) ) ;
private String positionName ;
private String sizeName ;
NameAttribute ( String positionName , String sizeName ) {
this . positionName = positionName ;
this . sizeName = sizeName ;
}
public String getPositionName ( ) {
return positionName ;
}
public String getSizeName ( ) {
return sizeName ;
}
}
private static final int RIGHT_PANE_WIDTH = 145 ;
public static UIExpandablePane createBoundsPane ( UISpinner width , UISpinner height ) {
@ -25,8 +50,8 @@ public class WidgetBoundsPaneFactory {
double f = TableLayout . FILL ;
double p = TableLayout . PREFERRED ;
Component [ ] [ ] components = new Component [ ] [ ] {
new Component [ ] { FRWidgetFactory . createLineWrapLabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Component_Size" ) ) , createRightPane ( width , height ) } ,
new Component [ ] { null , createRightPane ( new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Tree_Width" ) , SwingConstants . CENTER ) , new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Tree_Height" ) , SwingConstants . CENTER ) ) } ,
new Component [ ] { FRWidgetFactory . createLineWrapLabel ( Toolkit . i18nText ( "Fine-Design_Basic_Component_Size" ) ) , createRightPane ( width , height ) } ,
new Component [ ] { null , createRightPane ( new UILabel ( Toolkit . i18nText ( "Fine-Design_Basic_Tree_Width" ) , SwingConstants . CENTER ) , new UILabel ( Toolkit . i18nText ( "Fine-Design_Basic_Tree_Height" ) , SwingConstants . CENTER ) ) } ,
} ;
double [ ] rowSize = { p , p } ;
double [ ] columnSize = { f , RIGHT_PANE_WIDTH } ;
@ -34,9 +59,10 @@ public class WidgetBoundsPaneFactory {
final JPanel panel = TableLayoutHelper . createGapTableLayoutPane ( components , rowSize , columnSize , rowCount , IntervalConstants . INTERVAL_W5 , IntervalConstants . INTERVAL_L6 ) ;
panel . setBorder ( BorderFactory . createEmptyBorder ( 10 , 0 , 10 , 0 ) ) ;
boundsPane . add ( panel ) ;
return new UIExpandablePane ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Coords_And_Size" ) , 280 , 24 , boundsPane ) ;
return new UIExpandablePane ( Toolkit . i18nText ( "Fine-Design_Form_Coords_And_Size" ) , 280 , 24 , boundsPane ) ;
}
public static JPanel createRightPane ( Component com1 , Component com2 ) {
public static JPanel createRightPane ( Component com1 , Component com2 ) {
double f = TableLayout . FILL ;
double p = TableLayout . PREFERRED ;
double [ ] rowSize = { p } ;
@ -48,17 +74,17 @@ public class WidgetBoundsPaneFactory {
return TableLayoutHelper . createGapTableLayoutPane ( components , rowSize , columnSize , rowCount , IntervalConstants . INTERVAL_L6 , IntervalConstants . INTERVAL_L1 ) ;
}
public static UIExpandablePane createAbsoluteBoundsPane ( UISpinner x , UISpinner y , UISpinner width , UISpinner height ) {
public static UIExpandablePane createAbsoluteBoundsPane ( UISpinner x , UISpinner y , UISpinner width , UISpinner height , NameAttribute nameAttribute ) {
double f = TableLayout . FILL ;
double p = TableLayout . PREFERRED ;
Component [ ] [ ] northComponents = new Component [ ] [ ] {
new Component [ ] { FRWidgetFactory . createLineWrapLabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Component_Position" ) ) , createRightPane ( x , y ) } ,
new Component [ ] { null , createRightPane ( new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_X_Coordinate" ) , SwingConstants . CENTER ) , new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Y_Coordinate" ) , SwingConstants . CENTER ) ) } ,
new Component [ ] { FRWidgetFactory . createLineWrapLabel ( nameAttribute . getPositionName ( ) ) , createRightPane ( x , y ) } ,
new Component [ ] { null , createRightPane ( new UILabel ( Toolkit . i18nText ( "Fine-Design_Basic_X_Coordinate" ) , SwingConstants . CENTER ) , new UILabel ( Toolkit . i18nText ( "Fine-Design_Basic_Y_Coordinate" ) , SwingConstants . CENTER ) ) } ,
} ;
Component [ ] [ ] centerComponents = new Component [ ] [ ] {
new Component [ ] { FRWidgetFactory . createLineWrapLabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Component_Size" ) ) , createRightPane ( width , height ) } ,
new Component [ ] { null , createRightPane ( new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Tree_Width" ) , SwingConstants . CENTER ) , new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Tree_Height" ) , SwingConstants . CENTER ) ) } ,
new Component [ ] { FRWidgetFactory . createLineWrapLabel ( nameAttribute . getSizeName ( ) ) , createRightPane ( width , height ) } ,
new Component [ ] { null , createRightPane ( new UILabel ( Toolkit . i18nText ( "Fine-Design_Basic_Tree_Width" ) , SwingConstants . CENTER ) , new UILabel ( Toolkit . i18nText ( "Fine-Design_Basic_Tree_Height" ) , SwingConstants . CENTER ) ) } ,
} ;
double [ ] rowSize = { p , p } ;
double [ ] columnSize = { f , RIGHT_PANE_WIDTH } ;
@ -70,7 +96,11 @@ public class WidgetBoundsPaneFactory {
centerPanel . setBorder ( BorderFactory . createEmptyBorder ( 0 , 0 , 10 , 0 ) ) ;
boundsPane . add ( northPanel , BorderLayout . NORTH ) ;
boundsPane . add ( centerPanel , BorderLayout . CENTER ) ;
return new UIExpandablePane ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Coords_And_Size" ) , 230 , 24 , boundsPane ) ;
return new UIExpandablePane ( Toolkit . i18nText ( "Fine-Design_Form_Coords_And_Size" ) , 230 , 24 , boundsPane ) ;
}
public static UIExpandablePane createAbsoluteBoundsPane ( UISpinner x , UISpinner y , UISpinner width , UISpinner height ) {
return createAbsoluteBoundsPane ( x , y , width , height , NameAttribute . DEFAULT ) ;
}
@ -79,7 +109,7 @@ public class WidgetBoundsPaneFactory {
double f = TableLayout . FILL ;
double p = TableLayout . PREFERRED ;
Component [ ] [ ] components = new Component [ ] [ ] {
new Component [ ] { new UILabel ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Basic_Component_Size" ) ) , width } ,
new Component [ ] { new UILabel ( Toolkit . i18nText ( "Fine-Design_Basic_Component_Size" ) ) , width } ,
} ;
double [ ] rowSize = { p } ;
double [ ] columnSize = { p , f } ;
@ -87,6 +117,6 @@ public class WidgetBoundsPaneFactory {
final JPanel panel = TableLayoutHelper . createGapTableLayoutPane ( components , rowSize , columnSize , rowCount , IntervalConstants . INTERVAL_W1 , IntervalConstants . INTERVAL_L6 ) ;
panel . setBorder ( BorderFactory . createEmptyBorder ( 10 , 0 , 10 , 0 ) ) ;
boundsPane . add ( panel ) ;
return new UIExpandablePane ( com . fr . design . i18n . Toolkit . i18nText ( "Fine-Design_Form_Coords_And_Size" ) , 280 , 24 , boundsPane ) ;
return new UIExpandablePane ( Toolkit . i18nText ( "Fine-Design_Form_Coords_And_Size" ) , 280 , 24 , boundsPane ) ;
}
}