View Javadoc

1   package org.sat4j.sat.visu;
2   
3   import info.monitorenter.gui.chart.Chart2D;
4   
5   import java.awt.BorderLayout;
6   import java.awt.Color;
7   import java.awt.Font;
8   
9   import javax.swing.JLabel;
10  import javax.swing.JPanel;
11  import javax.swing.border.EmptyBorder;
12  
13  public class MyChartPanel extends JPanel {
14  
15      /**
16       * 
17       */
18      private static final long serialVersionUID = 1L;
19      private JLabel titleLabel;
20  
21      public MyChartPanel(Chart2D chart, String title) {
22          this(chart, title, Color.WHITE, Color.BLACK);
23      }
24  
25      public MyChartPanel(Chart2D chart, String title, Color bg, Color fg) {
26          super();
27          this.titleLabel = new JLabel(title);
28  
29          Font f = this.titleLabel.getFont();
30  
31          chart.setBackground(bg);
32          chart.setForeground(fg);
33  
34          // bold
35          this.titleLabel.setFont(f.deriveFont(f.getStyle() ^ Font.BOLD));
36  
37          this.titleLabel.setBackground(bg);
38          this.titleLabel.setForeground(fg);
39  
40          this.setBorder(new EmptyBorder(4, 4, 4, 4));
41          this.setLayout(new BorderLayout());
42  
43          JPanel labelPanel = new JPanel();
44  
45          labelPanel.add(this.titleLabel);
46          this.add(labelPanel, BorderLayout.NORTH);
47          this.add(chart, BorderLayout.CENTER);
48      }
49  
50  }