Source code: demo/tucson/multimedia/Gui.java
1 /*
2 * Multimedia TuCSoN Demo - Copyright (C) 2001 deis.unibo.it
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library 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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 package demo.tucson.multimedia;
19
20 /**
21 * GUI Service used by Master Agent to display image
22 *
23 * @author Alessandro Ricci
24 */
25 public class Gui extends javax.swing.JFrame {
26
27 private java.awt.image.BufferedImage image;
28 int sizeX;
29 int sizeY;
30
31 /** Creates new form Gui */
32 public Gui(int wx,int wy) {
33 sizeX=wx;
34 sizeY=wy;
35 initComponents ();
36 image = new java.awt.image.BufferedImage(sizeX,sizeY,java.awt.image.BufferedImage.TYPE_INT_ARGB);
37 pack ();
38 }
39
40 /** This method is called from within the constructor to
41 * initialize the form.
42 * WARNING: Do NOT modify this code. The content of this method is
43 * always regenerated by the FormEditor.
44 */
45 private void initComponents() {//GEN-BEGIN:initComponents
46 jPanel1 = new javax.swing.JPanel();
47 laImage = new javax.swing.JLabel();
48 getContentPane().setLayout(new java.awt.GridBagLayout());
49 java.awt.GridBagConstraints gridBagConstraints1;
50 addWindowListener(new java.awt.event.WindowAdapter() {
51 public void windowClosing(java.awt.event.WindowEvent evt) {
52 exitForm(evt);
53 }
54 }
55 );
56
57 jPanel1.setLayout(new java.awt.GridBagLayout());
58 java.awt.GridBagConstraints gridBagConstraints2;
59 jPanel1.setBorder(new javax.swing.border.LineBorder(java.awt.Color.black));
60
61 laImage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
62 gridBagConstraints2 = new java.awt.GridBagConstraints();
63 gridBagConstraints2.gridx = 0;
64 gridBagConstraints2.gridy = 0;
65 gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
66 gridBagConstraints2.weightx = 1.0;
67 gridBagConstraints2.weighty = 1.0;
68 jPanel1.add(laImage, gridBagConstraints2);
69
70
71 gridBagConstraints1 = new java.awt.GridBagConstraints();
72 gridBagConstraints1.gridx = 0;
73 gridBagConstraints1.gridy = 0;
74 gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
75 gridBagConstraints1.weightx = 1.0;
76 gridBagConstraints1.weighty = 1.0;
77 getContentPane().add(jPanel1, gridBagConstraints1);
78
79 }//GEN-END:initComponents
80
81 /** Exit the Application */
82 private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
83 System.exit (0);
84 }//GEN-LAST:event_exitForm
85
86 public void update(int[] imageData){
87 image.setRGB(0,0,sizeX,sizeY,imageData,0,sizeX);
88 laImage.setIcon(new javax.swing.ImageIcon(image));
89 pack();
90 show();
91 }
92 // Variables declaration - do not modify//GEN-BEGIN:variables
93 private javax.swing.JPanel jPanel1;
94 private javax.swing.JLabel laImage;
95 // End of variables declaration//GEN-END:variables
96
97 }