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 Chart2D chart;
20      private JLabel titleLabel;
21  
22      // private String titleText;
23  
24      public MyChartPanel(Chart2D chart, String title) {
25          this(chart, title, Color.WHITE, Color.BLACK);
26      }
27  
28      public MyChartPanel(Chart2D chart, String title, Color bg, Color fg) {
29          super();
30          // this.chart = chart;
31          // this.titleText = title;
32          this.titleLabel = new JLabel(title);
33  
34          Font f = this.titleLabel.getFont();
35  
36          chart.setBackground(bg);
37          chart.setForeground(fg);
38  
39          // bold
40          this.titleLabel.setFont(f.deriveFont(f.getStyle() ^ Font.BOLD));
41  
42          this.titleLabel.setBackground(bg);
43          this.titleLabel.setForeground(fg);
44  
45          // this.setBorder(new CompoundBorder(new TitledBorder(null, "",
46          // TitledBorder.LEFT, TitledBorder.TOP), new EmptyBorder(2, 2, 2, 2)));
47          this.setBorder(new EmptyBorder(4, 4, 4, 4));
48          this.setLayout(new BorderLayout());
49  
50          JPanel labelPanel = new JPanel();
51  
52          labelPanel.add(this.titleLabel);
53          this.add(labelPanel, BorderLayout.NORTH);
54          this.add(chart, BorderLayout.CENTER);
55      }
56  
57  }