33import cn .fudoc .trade .view .dto .HoldStockDataDto ;
44import cn .fudoc .trade .view .render .ProfitRenderer ;
55import cn .fudoc .trade .view .render .RankListCellRenderer ;
6+ import com .intellij .ui .JBColor ;
67import com .intellij .ui .components .JBList ;
78import com .intellij .ui .components .JBScrollPane ;
89import lombok .Getter ;
@@ -51,11 +52,34 @@ public TodayProfitView() {
5152 JPanel rankPanel = new JPanel (new BorderLayout ());
5253 this .rankListModel = new DefaultListModel <>();
5354 this .rankList = new JBList <>(this .rankListModel );
55+ this .rankList .setFixedCellHeight (40 );
56+ this .rankList .setFont (this .rankList .getFont ().deriveFont (15.0f ));
5457 this .rankList .setCellRenderer (new RankListCellRenderer ());
58+ rankPanel .add (createProfitPanel (), BorderLayout .NORTH );
5559 rankPanel .add (new JBScrollPane (this .rankList ), BorderLayout .CENTER );
5660 this .rootPanel .add (rankPanel , BorderLayout .CENTER );
5761 }
5862
63+ private JPanel createProfitPanel () {
64+ JLabel rankLabel = new JLabel ("今日收益贡献度排名" );
65+ JLabel profitLabel = new JLabel ("今日收益" );
66+ rankLabel .setForeground (JBColor .GRAY );
67+ rankLabel .setFont (rankLabel .getFont ().deriveFont (13.0f ));
68+ profitLabel .setForeground (JBColor .GRAY );
69+ profitLabel .setFont (rankLabel .getFont ().deriveFont (13.0f ));
70+ JPanel titlePanel = new JPanel ();
71+ titlePanel .setLayout (new BoxLayout (titlePanel , BoxLayout .X_AXIS ));
72+ titlePanel .add (Box .createHorizontalGlue ());
73+ titlePanel .add (rankLabel );
74+ titlePanel .add (Box .createHorizontalGlue ());
75+ titlePanel .add (profitLabel );
76+ titlePanel .add (Box .createHorizontalGlue ());
77+ titlePanel .setPreferredSize (new Dimension (titlePanel .getWidth (), 50 ));
78+ titlePanel .setSize (new Dimension (titlePanel .getWidth (), 50 ));
79+ titlePanel .setBorder (BorderFactory .createEmptyBorder (10 , 0 , 0 , 0 ));
80+ return titlePanel ;
81+ }
82+
5983
6084 public void setTodayProfit (String todayProfit ) {
6185 todayProfitPanel .setValue (todayProfit , true );
@@ -70,9 +94,8 @@ public void setCompanyValue(String companyValue) {
7094 }
7195
7296
73-
74- public void initData (List <HoldStockDataDto > dataList ){
97+ public void initData (List <HoldStockDataDto > dataList ) {
7598 this .rankListModel .clear ();
76- if (CollectionUtils .isNotEmpty (dataList )) this .rankListModel .addAll (dataList );
99+ if (CollectionUtils .isNotEmpty (dataList )) this .rankListModel .addAll (dataList );
77100 }
78101}
0 commit comments