@ -4,6 +4,8 @@ package com.fr.design.mainframe.chart.gui;
* Created by hufan on 2016 / 10 / 20 .
* /
import com.fine.theme.utils.FineLayoutBuilder ;
import com.formdev.flatlaf.util.ScaledEmptyBorder ;
import com.fr.base.BaseFormula ;
import com.fr.base.Utils ;
import com.fr.chart.base.AttrChangeConfig ;
@ -20,22 +22,16 @@ import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIToggleButton ;
import com.fr.design.gui.ilable.UILabel ;
import com.fr.design.gui.ispinner.UISpinner ;
import com.fr.design.layout.TableLayout ;
import com.fr.design.layout.TableLayoutHelper ;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane ;
import com.fr.stable.StableUtils ;
import com.fr.stable.StringUtils ;
import com.fr.van.chart.designer.TableLayout4VanChartHelper ;
import javax.swing.BorderFactory ;
import javax.swing.BoxLayout ;
import javax.swing.JPanel ;
import javax.swing.SwingConstants ;
import java.awt.BorderLayout ;
import java.awt.CardLayout ;
import java.awt.Component ;
import java.awt.Dimension ;
import java.awt.FlowLayout ;
import java.awt.event.ActionEvent ;
import java.awt.event.ActionListener ;
import java.awt.event.MouseAdapter ;
@ -44,20 +40,16 @@ import java.awt.event.MouseListener;
import java.util.ArrayList ;
import java.util.List ;
import static com.fine.theme.utils.FineUIScale.scale ;
import static com.fr.design.i18n.Toolkit.i18nText ;
/ * *
* 图表切换设置面板
* /
public class ChangeConfigPane extends BasicBeanPane < ChartCollection > {
private static final int WIDTH = 100 ;
private static final int EDIT_AREA_WIDTH = 180 ;
private static final int LABEL_WIDTH = 20 ;
private static final int WIDTH = scale ( 100 ) ;
private static final int MIN_TIME = 0 ;
private static final int MAX_TIME = Integer . MAX_VALUE ;
private static final int CONSTANT_TEN = 10 ;
private static final int CONSTANT_THIRTY = 30 ;
private static final int CONSTANT_ZERO = 0 ;
private static final int COL_COUNT = 4 ;
private JPanel contentPane ;
//配置方式按钮
@ -84,7 +76,7 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
public ChangeConfigPane ( ) {
init ( ) ;
this . setLayout ( new BorderLayout ( ) ) ;
this . setBorder ( BorderFactory . create EmptyBorder( 10 , 15 , 10 , 15 ) ) ;
this . setBorder ( new Scaled EmptyBorder( 10 , 10 , 10 , 10 ) ) ;
this . add ( createScrollPane ( ) , BorderLayout . CENTER ) ;
}
@ -101,20 +93,15 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
initButtonGroup ( ) ;
configPane = createConfigPane ( ) ;
contentPane = createContentPane ( ) ;
contentPane . setBorder ( BorderFactory . createEmptyBorder ( CONSTANT_TEN , CONSTANT_THIRTY , CONSTANT_TEN , CONSTANT_THIRTY ) ) ;
}
private JPanel createContentPane ( ) {
double p = TableLayout . PREFERRED ;
double f = TableLayout . FILL ;
double [ ] columnSize = { p , f } ;
double [ ] rowSize = { p , p , p } ;
Component [ ] [ ] components = new Component [ ] [ ] {
new Component [ ] { new UILabel ( i18nText ( "Fine-Design_Chart_Change_Style" ) ) , configStyleButton } ,
new Component [ ] { configPane , null } ,
new Component [ ] { createButtonContentPane ( ) , null }
} ;
return TableLayoutHelper . createTableLayoutPane ( components , rowSize , columnSize ) ;
return FineLayoutBuilder . compatibleTableLayout ( 10 , components , new double [ ] { 1 . 2 , 3 } ) ;
}
private JPanel createConfigPane ( ) {
@ -136,39 +123,29 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
panel . add ( buttonConfigPane , "button" ) ;
panel . add ( carouselConfigPane , "carousel" ) ;
panel . setBorder ( BorderFactory . createEmptyBorder ( CONSTANT_ZERO , CONSTANT_TEN , CONSTANT_ZERO , CONSTANT_ZERO ) ) ;
return panel ;
}
private JPanel createCarouseConfigPane ( ) {
double p = TableLayout . PREFERRED ;
double f = TableLayout . FILL ;
double [ ] columnSize = { p , f , p } ;
double [ ] rowSize = { p , p , p } ;
timeInterval = new UISpinner ( MIN_TIME , MAX_TIME , 1 , 0 ) ;
colorSelectBox4carousel = new ColorSelectBoxWithOutTransparent ( WIDTH ) ;
switchStyleGroup = new UIButtonGroup ( new String [ ] { i18nText ( "Fine-Design_Chart_Show" ) , i18nText ( "Fine-Design_Report_Hide" ) } ) ;
JPanel timeIntervalPane = FineLayoutBuilder . createHorizontalLayout ( 5 , timeInterval , new UILabel ( i18nText ( "Fine-Design_Chart_Time_Second" ) ) ) ;
Component [ ] [ ] components = new Component [ ] [ ] {
new Component [ ] { new UILabel ( i18nText ( "Fine-Design_Chart_Arrow_Style" ) ) , switchStyleGroup , null } ,
new Component [ ] { new UILabel ( i18nText ( "Fine-Design_Chart_Time_Interval" ) ) , timeInterval , new UILabel ( i18nText ( "Fine-Design_Chart_Time_Second" ) ) } ,
new Component [ ] { new UILabel ( i18nText ( "Fine-Design_Basic_Background" ) ) , colorSelectBox4carousel , null }
new Component [ ] { new UILabel ( i18nText ( "Fine-Design_Chart_Arrow_Style" ) ) , switchStyleGroup } ,
new Component [ ] { new UILabel ( i18nText ( "Fine-Design_Chart_Time_Interval" ) ) , timeIntervalPane } ,
new Component [ ] { new UILabel ( i18nText ( "Fine-Design_Basic_Background" ) ) , colorSelectBox4carousel }
} ;
return TableLayout4VanChartHelper . createGapTableLayoutPane ( components , rowSize , columnSize ) ;
return FineLayoutBuilder . compatibleTableLayout ( 10 , components , new double [ ] { 1 . 2 , 3 } ) ;
}
private JPanel createTitleStylePane ( ) {
final UILabel text = new UILabel ( i18nText ( "Fine-Design_Chart_Character" ) , SwingConstants . LEFT ) ;
styleAttrPane = new ChartTextAttrPane ( ) {
protected JPanel getContentPane ( JPanel buttonPane ) {
double p = TableLayout . PREFERRED ;
double f = TableLayout . FILL ;
double [ ] columnSize = { f , EDIT_AREA_WIDTH } ;
double [ ] rowSize = { p , p } ;
return TableLayout4VanChartHelper . createGapTableLayoutPane ( getComponents ( buttonPane ) , rowSize , columnSize ) ;
return FineLayoutBuilder . compatibleTableLayout ( 10 , getComponents ( buttonPane ) , new double [ ] { 1 . 2 , 3 } ) ;
}
protected Component [ ] [ ] getComponents ( JPanel buttonPane ) {
@ -184,54 +161,44 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
private JPanel createButtonBackgroundColorPane ( ) {
colorSelectBox4button = new ColorSelectBoxWithOutTransparent ( WIDTH ) ;
return TableLayout4VanChartHelper . createGapTableLayoutPane ( i18nText ( "Fine-Design_Basic_Background" ) , colorSelectBox4button , EDIT_AREA_WIDTH ) ;
return FineLayoutBuilder . createHorizontalLayout ( 0 , new double [ ] { 1 . 2 , 3 } ,
new UILabel ( i18nText ( "Fine-Design_Basic_Background" ) ) ,
colorSelectBox4button ) ;
}
private JPanel createButtonContentPane ( ) {
JPanel buttonContentPane = new JPanel ( new BorderLayout ( ) ) ;
JPanel buttonContentPane = new JPanel ( new BorderLayout ( 0 , scale ( 10 ) ) ) ;
chartTypesPane = new JPanel ( ) ;
chartTypesPane . setLayout ( new BoxLayout ( chartTypesPane , BoxLayout . Y_AXIS ) ) ;
chartTypesPane . setBorder ( BorderFactory . createEmptyBorder ( 0 , 5 , 0 , 0 ) ) ;
chartTypesPane . setLayout ( new BorderLayout ( ) ) ;
switchTitlePane . setLayout ( new CardLayout ( ) ) ;
JPanel titleEditPane = TableLayout4VanChartHelper . createGapTableLayoutPane (
i18nText ( "Fine-Design_Chart_Switch_Title_Label" ) ,
switchTitlePane ,
EDIT_AREA_WIDTH
JPanel titleEditPane = FineLayoutBuilder . createHorizontalLayout ( 0 , new double [ ] { 1 . 2 , 3 } ,
new UILabel ( i18nText ( "Fine-Design_Chart_Switch_Title_Label" ) ) ,
switchTitlePane
) ;
titleEditPane . setBorder ( BorderFactory . createEmptyBorder ( 0 , 10 , 0 , 0 ) ) ;
buttonContentPane . add ( chartTypesPane , BorderLayout . NORTH ) ;
buttonContentPane . add ( titleEditPane , BorderLayout . CENTER ) ;
UIExpandablePane expandablePane = new UIExpandablePane ( i18nText ( "Fine-Design_Chart_Button_And_Rotation_Content" ) , buttonContentPane ) {
protected void setcontentPanelontentPanelBorder ( ) {
}
} ;
expandablePane . setBorder ( BorderFactory . createEmptyBorder ( 20 , 0 , 0 , 0 ) ) ;
return expandablePane ;
return new UIExpandablePane ( i18nText ( "Fine-Design_Chart_Button_And_Rotation_Content" ) , buttonContentPane ) ;
}
private void populateButtonContentPane ( ChartCollection collection ) {
int count = collection . getChartCount ( ) ;
int select = collection . getSelectedIndex ( ) ;
JPanel pane = null ;
chartTypesPane . removeAll ( ) ;
ArrayList < Component > buttons = new ArrayList < > ( ) ;
for ( int i = 0 ; i < count ; i + + ) {
if ( i % COL_COUNT = = 0 ) {
pane = new JPanel ( new FlowLayout ( FlowLayout . LEFT ) ) ;
chartTypesPane . add ( pane ) ;
}
ChangeChartButton button = new ChangeChartButton ( i , collection ) ;
changeChartButtons . add ( button ) ;
button . setSelected ( i = = select ) ;
pane . add ( button ) ;
buttons . add ( button ) ;
populateSwitchTitlePane ( i , collection ) ;
}
chartTypesPane . add ( FineLayoutBuilder . createCommonTableLayout ( COL_COUNT , 10 , 10 , buttons ) ) ;
showSwitchTitleCard ( collection . getChartName ( select ) ) ;
chartTypesPane . revalidate ( ) ;
@ -258,22 +225,17 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
}
private JPanel createButtonConfigPane ( ) {
double p = TableLayout . PREFERRED ;
double f = TableLayout . FILL ;
double [ ] columnSize = { p , f } ;
double [ ] rowSize = { p , p , p } ;
Component [ ] [ ] components = new Component [ ] [ ] {
new Component [ ] { createTitleStylePane ( ) , null } ,
new Component [ ] { createButtonBackgroundColorPane ( ) , null } ,
} ;
return TableLayoutHelper . createTableLayoutPane ( components , rowSize , columnSize ) ;
return FineLayoutBuilder . compatibleTableLayout ( 10 , components , new double [ ] { 1 . 2 , 3 } ) ;
}
private void initButtonGroup ( ) {
configStyleButton = new UIButtonGroup < Integer > ( new String [ ] { i18nText ( "Fine-Design_Chart_Button_Style" ) ,
i18nText ( "Fine-Design_Chart_Carousel_Style" ) } ) ;
configStyleButton . setPreferredSize ( new Dimension ( WIDTH * 2 , ( int ) configStyleButton . getPreferredSize ( ) . getHeight ( ) ) ) ;
configStyleButton . addActionListener ( new ActionListener ( ) {
@Override
public void actionPerformed ( ActionEvent e ) {
@ -359,8 +321,6 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
}
private class ChangeChartButton extends UIToggleButton {
private static final int BUTTON_WIDTH = 52 ;
private static final int BUTTON_HEIGHT = 20 ;
private ChartCollection collection ;
private int buttonIndex ;
@ -384,9 +344,6 @@ public class ChangeConfigPane extends BasicBeanPane<ChartCollection> {
} ;
}
public Dimension getPreferredSize ( ) {
return new Dimension ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
}
}
private void resetChangeChartButtons ( ) {