001: /*
002: * Copyright (C) 2005 - 2008 JasperSoft Corporation. All rights reserved.
003: * http://www.jaspersoft.com.
004: *
005: * Unless you have purchased a commercial license agreement from JasperSoft,
006: * the following license terms apply:
007: *
008: * This program is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License version 2 as published by
010: * the Free Software Foundation.
011: *
012: * This program is distributed WITHOUT ANY WARRANTY; and without the
013: * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014: * See the GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018: * or write to:
019: *
020: * Free Software Foundation, Inc.,
021: * 59 Temple Place - Suite 330,
022: * Boston, MA USA 02111-1307
023: *
024: *
025: *
026: *
027: * SampleBoxPanel.java
028: *
029: * Created on 29 novembre 2004, 18.16
030: *
031: */
032:
033: package it.businesslogic.ireport.gui.box;
034:
035: import it.businesslogic.ireport.*;
036: import java.awt.*;
037:
038: /**
039: *
040: * @author Administrator
041: */
042: public class SampleBoxPanel extends javax.swing.JPanel {
043:
044: private Box box;
045:
046: /** Creates new form SampleBoxPanel */
047: public SampleBoxPanel() {
048: initComponents();
049: this .setBackground(Color.WHITE);
050: setBox(new Box());
051: }
052:
053: public Box getBox() {
054: return box;
055: }
056:
057: public void setBox(Box box) {
058: this .box = box;
059: this .invalidate();
060: this .repaint();
061: }
062:
063: public void refresh() {
064: this .invalidate();
065: this .repaint();
066: }
067:
068: public void paint(Graphics g2) {
069: Graphics2D g = (Graphics2D) g2;
070: g.clearRect(0, 0, this .getWidth(), this .getHeight());
071: g.setColor(Color.LIGHT_GRAY);
072: Stroke oldStroke = g.getStroke();
073: Color oldColor = g.getColor();
074:
075: g.fillRect(10, 10, this .getWidth() - 20, this .getHeight() - 20);
076:
077: if (!getBox().getLeftBorder().equals("None")) {
078: Stroke stroke = ReportElement.getPenStroke(getBox()
079: .getLeftBorder(), null, 1.0);
080: g.setStroke(stroke);
081: g.setColor(getBox().getLeftBorderColor());
082: g.drawLine(10, 10, 10, this .getHeight() - 10);
083: }
084:
085: if (!getBox().getRightBorder().equals("None")) {
086: Stroke stroke = ReportElement.getPenStroke(getBox()
087: .getRightBorder(), null, 1.0);
088: g.setStroke(stroke);
089: g.setColor(getBox().getRightBorderColor());
090: g.drawLine(this .getWidth() - 10, 10, this .getWidth() - 10,
091: this .getHeight() - 10);
092: }
093:
094: if (!getBox().getTopBorder().equals("None")) {
095: Stroke stroke = ReportElement.getPenStroke(getBox()
096: .getTopBorder(), null, 1.0);
097: g.setStroke(stroke);
098: g.setColor(getBox().getTopBorderColor());
099: g.drawLine(10, 10, this .getWidth() - 10, 10);
100: }
101:
102: if (!getBox().getBottomBorder().equals("None")) {
103: Stroke stroke = ReportElement.getPenStroke(getBox()
104: .getBottomBorder(), null, 1.0);
105: g.setStroke(stroke);
106: g.setColor(getBox().getBottomBorderColor());
107: g.drawLine(10, this .getHeight() - 10, this .getWidth() - 10,
108: this .getHeight() - 10);
109: }
110:
111: g.setColor(oldColor);
112: g.setStroke(oldStroke);
113: }
114:
115: /** This method is called from within the constructor to
116: * initialize the form.
117: * WARNING: Do NOT modify this code. The content of this method is
118: * always regenerated by the Form Editor.
119: */
120: private void initComponents() {//GEN-BEGIN:initComponents
121:
122: setLayout(new java.awt.BorderLayout());
123:
124: }//GEN-END:initComponents
125:
126: // Variables declaration - do not modify//GEN-BEGIN:variables
127: // End of variables declaration//GEN-END:variables
128:
129: }
|