KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > businesslogic > ireport > gui > box > SampleBoxPanel


1 /*
2  * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.
3  * http://www.jaspersoft.com.
4  *
5  * Unless you have purchased a commercial license agreement from JasperSoft,
6  * the following license terms apply:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  *
12  * This program is distributed WITHOUT ANY WARRANTY; and without the
13  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
18  * or write to:
19  *
20  * Free Software Foundation, Inc.,
21  * 59 Temple Place - Suite 330,
22  * Boston, MA USA 02111-1307
23  *
24  *
25  *
26  *
27  * SampleBoxPanel.java
28  *
29  * Created on 29 novembre 2004, 18.16
30  *
31  */

32
33 package it.businesslogic.ireport.gui.box;
34 import it.businesslogic.ireport.*;
35 import java.awt.*;
36 /**
37  *
38  * @author Administrator
39  */

40 public class SampleBoxPanel extends javax.swing.JPanel JavaDoc {
41     
42     private Box box;
43     
44     /** Creates new form SampleBoxPanel */
45     public SampleBoxPanel() {
46         initComponents();
47         this.setBackground(Color.WHITE);
48         setBox(new Box());
49     }
50
51     public Box getBox() {
52         return box;
53     }
54
55     public void setBox(Box box) {
56         this.box = box;
57         this.invalidate();
58         this.repaint();
59     }
60     
61     public void refresh() {
62         this.invalidate();
63         this.repaint();
64     }
65     
66     public void paint(Graphics g2)
67     {
68         Graphics2D g = (Graphics2D)g2;
69         g.clearRect(0,0,this.getWidth(),this.getHeight());
70         g.setColor( Color.LIGHT_GRAY);
71         Stroke oldStroke = g.getStroke();
72         Color oldColor = g.getColor();
73
74         g.fillRect(10, 10, this.getWidth()-20, this.getHeight()-20);
75         
76         if (!getBox().getLeftBorder().equals("None"))
77         {
78             Stroke stroke = ReportElement.getPenStroke( getBox().getLeftBorder(), 1.0);
79             g.setStroke(stroke);
80             g.setColor(getBox().getLeftBorderColor());
81             g.drawLine(10, 10, 10, this.getHeight()-10);
82         }
83         
84         if (!getBox().getRightBorder().equals("None"))
85         {
86             Stroke stroke = ReportElement.getPenStroke( getBox().getRightBorder(), 1.0);
87             g.setStroke(stroke);
88             g.setColor(getBox().getRightBorderColor());
89             g.drawLine(this.getWidth()-10, 10, this.getWidth()-10, this.getHeight()-10);
90         }
91         
92         if (!getBox().getTopBorder().equals("None"))
93         {
94             Stroke stroke = ReportElement.getPenStroke( getBox().getTopBorder(), 1.0);
95             g.setStroke(stroke);
96             g.setColor(getBox().getTopBorderColor());
97             g.drawLine(10, 10, this.getWidth()-10, 10);
98         }
99         
100         if (!getBox().getBottomBorder().equals("None"))
101         {
102             Stroke stroke = ReportElement.getPenStroke( getBox().getBottomBorder(), 1.0);
103             g.setStroke(stroke);
104             g.setColor(getBox().getBottomBorderColor());
105             g.drawLine(10, this.getHeight()-10, this.getWidth()-10, this.getHeight()-10);
106         }
107         
108         g.setColor(oldColor);
109         g.setStroke(oldStroke);
110     }
111     
112     
113     /** This method is called from within the constructor to
114      * initialize the form.
115      * WARNING: Do NOT modify this code. The content of this method is
116      * always regenerated by the Form Editor.
117      */

118     private void initComponents() {//GEN-BEGIN:initComponents
119

120         setLayout(new java.awt.BorderLayout JavaDoc());
121
122     }//GEN-END:initComponents
123

124     
125     // Variables declaration - do not modify//GEN-BEGIN:variables
126
// End of variables declaration//GEN-END:variables
127

128 }
129
Popular Tags