01: //** Copyright Statement ***************************************************
02: //The Salmon Open Framework for Internet Applications (SOFIA)
03: //Copyright (C) 1999 - 2003, Salmon LLC
04: //
05: //This program is free software; you can redistribute it and/or
06: //modify it under the terms of the GNU General Public License version 2
07: //as published by the Free Software Foundation;
08: //
09: //This program is distributed in the hope that it will be useful,
10: //but WITHOUT ANY WARRANTY; without even the implied warranty of
11: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: //GNU General Public License for more details.
13: //
14: //You should have received a copy of the GNU General Public License
15: //along with this program; if not, write to the Free Software
16: //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: //
18: //For more information please visit http://www.salmonllc.com
19: //** End Copyright Statement ***************************************************
20:
21: package com.salmonllc.jasperReports;
22:
23: import java.awt.GridLayout;
24:
25: import javax.swing.BorderFactory;
26: import javax.swing.JLabel;
27: import javax.swing.JPanel;
28:
29: /**
30: * A panel that displays status messages for the viewer
31: */
32: public class SJasperViewInfo extends JPanel {
33:
34: JLabel _message;
35: JLabel _page;
36: JLabel _zoom;
37: MessageDisplayer _messageDisplayer;
38:
39: /**
40: * Creates a new viewer info object for the viewer
41: */
42: public SJasperViewInfo() {
43: super ();
44: setLayout(new GridLayout(1, 2));
45: add(_message = new JLabel(" "));
46:
47: JPanel p = new JPanel(new GridLayout(1, 2));
48: p.add(_page = new JLabel(" "));
49: p.add(_zoom = new JLabel(" "));
50: add(p);
51:
52: _message.setBorder(BorderFactory.createLoweredBevelBorder());
53: _zoom.setBorder(BorderFactory.createLoweredBevelBorder());
54: _page.setBorder(BorderFactory.createLoweredBevelBorder());
55: }
56:
57: /**
58: * Creates a new viewer info object for the viewer
59: * @param disp The MessageDisplayer allows the info object to be used from an applet or an application. For an applet the messages should go to the browsers status box.
60: */
61: public SJasperViewInfo(MessageDisplayer disp) {
62: this ();
63: _messageDisplayer = disp;
64: }
65:
66: /**
67: * Set the message to be displayed in the status box
68: */
69: public void setMessage(String message) {
70: if (message == null)
71: message = " ";
72: _message.setText(message);
73: if (_messageDisplayer != null)
74: _messageDisplayer.displayMessage(message);
75: }
76:
77: /**
78: * Sets the page n of n status box
79: */
80: public void setPageMessage(int page, int noPages) {
81: if (noPages == 0)
82: page = 0;
83: _page.setText("Page: " + page + " of " + noPages);
84: }
85:
86: /**
87: * Sets the zoom percentage message box
88: */
89: public void setZoomMessage(float zoom) {
90: int z = (int) (zoom * 100);
91: _zoom.setText("Zoom: " + z + "%");
92: }
93: }
|