Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools / src / com / iver / cit / gvsig / rasterTools / saveRaster / ui / info / EndInfoPanel.java @ 4532

History | View | Annotate | Download (8.27 KB)

1
package com.iver.cit.gvsig.rasterTools.saveRaster.ui.info;
2

    
3
import java.awt.Dimension;
4
import java.awt.FlowLayout;
5
import java.awt.GridBagConstraints;
6
import java.awt.GridBagLayout;
7

    
8
import javax.swing.JButton;
9
import javax.swing.JLabel;
10
import javax.swing.JPanel;
11

    
12
public class EndInfoPanel extends JPanel {
13

    
14
        private JPanel pFile = null;
15
        private JPanel pTime = null;
16
        private JPanel pButtons = null;
17
        private JLabel lTimeTag = null;
18
        private JButton jButton = null;
19
        private JPanel pCompression = null;
20
        private JLabel lFileNameTag = null;
21
        private JLabel lSize = null;
22
        private JLabel lSizeTag = null;
23
        private JLabel lTime = null;
24
        private JLabel lCompressTag = null;
25
        private JLabel lCompress = null;
26
        private JPanel jPanel = null;
27
        private JPanel pMain = null;
28
        private JLabel lFile = null;
29
        /**
30
         * This is the default constructor
31
         */
32
        public EndInfoPanel() {
33
                super();
34
                initialize();
35
        }
36

    
37
        /**
38
         * This method initializes this
39
         * 
40
         * @return void
41
         */
42
        private void initialize() {
43
                GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
44
                gridBagConstraints4.gridx = 0;
45
                gridBagConstraints4.gridy = 0;
46
                GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
47
                gridBagConstraints2.gridx = 0;
48
                gridBagConstraints2.gridy = 1;
49
                this.setLayout(new GridBagLayout());
50
                this.setSize(482, 130);
51
                this.setPreferredSize(new java.awt.Dimension(472,75));
52
                this.add(getJPanel12(), gridBagConstraints4);
53
                this.add(getJPanel2(), gridBagConstraints2);
54
        }
55

    
56
        /**
57
         * This method initializes jPanel        
58
         *         
59
         * @return javax.swing.JPanel        
60
         */
61
        private JPanel getJPanel() {
62
                if (pFile == null) {
63
                        lFile = new JLabel();
64
                        lFile.setText("");
65
                        lFile.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
66
                        lFile.setPreferredSize(new java.awt.Dimension(410,15));
67
                        FlowLayout flowLayout = new FlowLayout();
68
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
69
                        flowLayout.setHgap(5);
70
                        pFile = new JPanel();
71
                        pFile.setLayout(flowLayout);
72
                        pFile.setPreferredSize(new java.awt.Dimension(472,25));
73
                        lFileNameTag = new JLabel();
74
                        lFileNameTag.setText("File:");
75
                        pFile.add(lFileNameTag, null);
76
                        pFile.add(lFile, null);
77
                }
78
                return pFile;
79
        }
80

    
81
        /**
82
         * This method initializes jPanel1        
83
         *         
84
         * @return javax.swing.JPanel        
85
         */
86
        private JPanel getJPanel1() {
87
                if (pTime == null) {
88
                        lTime = new JLabel();
89
                        lTime.setText("");
90
                        lTime.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
91
                        lTime.setPreferredSize(new java.awt.Dimension(170,15));
92
                        lSizeTag = new JLabel();
93
                        lSizeTag.setText("Size: ");
94
                        FlowLayout flowLayout1 = new FlowLayout();
95
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
96
                        flowLayout1.setHgap(5);
97
                        lSize = new JLabel();
98
                        lSize.setText("");
99
                        lSize.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
100
                        lSize.setPreferredSize(new java.awt.Dimension(170,15));
101
                        lTimeTag = new JLabel();
102
                        lTimeTag.setText("Time:");
103
                        pTime = new JPanel();
104
                        pTime.setLayout(flowLayout1);
105
                        pTime.setPreferredSize(new java.awt.Dimension(472,25));
106
                        pTime.add(lTimeTag, null);
107
                        pTime.add(lTime, null);
108
                        pTime.add(lSizeTag, null);
109
                        pTime.add(lSize, null);
110
                }
111
                return pTime;
112
        }
113

    
114
        /**
115
         * This method initializes jPanel2        
116
         *         
117
         * @return javax.swing.JPanel        
118
         */
119
        private JPanel getJPanel2() {
120
                if (pButtons == null) {
121
                        FlowLayout flowLayout2 = new FlowLayout();
122
                        flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
123
                        flowLayout2.setHgap(15);
124
                        pButtons = new JPanel();
125
                        pButtons.setLayout(flowLayout2);
126
                        pButtons.setPreferredSize(new java.awt.Dimension(472,30));
127
                        pButtons.add(getBAccept(), null);
128
                }
129
                return pButtons;
130
        }
131

    
132
        /**
133
         * This method initializes jButton        
134
         *         
135
         * @return javax.swing.JButton        
136
         */
137
        public JButton getBAccept() {
138
                if (jButton == null) {
139
                        jButton = new JButton();
140
                        jButton.setText("Aceptar");
141
                }
142
                return jButton;
143
        }
144

    
145
        /**
146
         * This method initializes jPanel        
147
         *         
148
         * @return javax.swing.JPanel        
149
         */
150
        private JPanel getJPanel3() {
151
                if (pCompression == null) {
152
                        FlowLayout flowLayout3 = new FlowLayout();
153
                        flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
154
                        flowLayout3.setHgap(5);
155
                        lCompress = new JLabel();
156
                        lCompress.setText("");
157
                        lCompress.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
158
                        lCompress.setPreferredSize(new java.awt.Dimension(50,15));
159
                        lCompressTag = new JLabel();
160
                        lCompressTag.setText("Compression:");
161
                        pCompression = new JPanel();
162
                        pCompression.setLayout(flowLayout3);
163
                        pCompression.setPreferredSize(new java.awt.Dimension(472,25));
164
                        pCompression.add(lCompressTag, null);
165
                        pCompression.add(lCompress, null);
166
                }
167
                return pCompression;
168
        }
169

    
170
        /**
171
         * This method initializes jPanel        
172
         *         
173
         * @return javax.swing.JPanel        
174
         */
175
        private JPanel getJPanel4() {
176
                if (jPanel == null) {
177
                        jPanel = new JPanel();
178
                        jPanel.setPreferredSize(new java.awt.Dimension(472,0));
179
                }
180
                return jPanel;
181
        }
182
        
183
        /**
184
         * This method initializes jPanel1        
185
         *         
186
         * @return javax.swing.JPanel        
187
         */
188
        private JPanel getJPanel12() {
189
                if (pMain == null) {
190
                        GridBagConstraints gridBagConstraints = new GridBagConstraints();
191
                        gridBagConstraints.gridx = 0;
192
                        gridBagConstraints.gridy = 0;
193
                        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
194
                        gridBagConstraints1.gridx = 0;
195
                        gridBagConstraints1.gridy = 1;
196
                        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
197
                        gridBagConstraints3.gridx = 0;
198
                        gridBagConstraints3.gridy = 3;
199
                        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
200
                        gridBagConstraints11.gridx = 0;
201
                        gridBagConstraints11.gridy = 2;
202
                        pMain = new JPanel();
203
                        pMain.setLayout(new GridBagLayout());
204
                        pMain.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1), "Estadisticas", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
205
                        pMain.setPreferredSize(new java.awt.Dimension(482,100));
206
                        pMain.add(getJPanel4(), gridBagConstraints3);
207
                        pMain.add(getJPanel3(), gridBagConstraints11);
208
                        pMain.add(getJPanel1(), gridBagConstraints1);
209
                        pMain.add(getJPanel(), gridBagConstraints);
210
                }
211
                return pMain;
212
        }
213
        
214
        //---------------------------
215

    
216
        protected JLabel getLCompressTag() {
217
                return lCompressTag;
218
        }
219

    
220
        protected JLabel getLFileNameTag() {
221
                return lFileNameTag;
222
        }
223

    
224
        protected JLabel getLSizeTag() {
225
                return lSizeTag;
226
        }
227

    
228
        protected JLabel getLTimeTag() {
229
                return lTimeTag;
230
        }
231

    
232
        public JLabel getLCompress() {
233
                return lCompress;
234
        }
235

    
236
        public void setFileName(String fileName) {
237
                lFile.setText(fileName);
238
        }
239

    
240
        /**
241
         * Asigna el tama?o del fichero que ha sido salvado. Se pasa como par?metro el
242
         * tama?o en bytes y esta funci?n se encarga de parsearlo en bytes, Kilobytes, 
243
         * Megabytes y Gigabytes mostrandolo como cadena.
244
         * @param size Longitud en bytes.
245
         */
246
        public void setSize(long size) {
247
                int bytes = (int)size, kBytes = 0, mBytes = 0, gBytes = 0;
248
                if(size >= 1024){
249
                        kBytes = (int)(size / 1024);
250
                        bytes = (int)(size - (kBytes * 1024));
251
                        if(kBytes >= 1024){
252
                                mBytes = (int)(kBytes / 1024);
253
                                kBytes = (int)(kBytes - (mBytes * 1024));
254
                                if(mBytes >= 1024){
255
                                        gBytes = (int)(mBytes / 1024);
256
                                        mBytes = (int)(mBytes - (gBytes * 1024));
257
                                }
258
                        }
259
                }
260
                StringBuffer s = new StringBuffer();
261
                if(gBytes != 0)
262
                        s.append(gBytes+"GB ");
263
                if(mBytes != 0)
264
                        s.append(mBytes+"MB ");
265
                if(kBytes != 0)
266
                        s.append(kBytes+"KB ");
267
                if(bytes != 0)
268
                        s.append(bytes+"B ");
269
                lSize.setText(s.toString());        
270
        }
271

    
272
        /**
273
         * Asigna el tiempo que ha tardado para la compresi?n en milisegundos.
274
         * Esta funci?n se encarga de parsearlo en dias, horas, minutos y segundos.
275
         * @param time Tiempo en milisegundos
276
         */
277
        public void setTime(long time){
278
                int days = 0, hours = 0, minuts = 0, seconds = (int)(time / 1000D);
279
                if(seconds >= 60){
280
                        minuts = (int)(seconds / 60);
281
                        seconds = (int)(seconds - (minuts * 60));
282
                        if(minuts >= 60){
283
                                hours = (int)(minuts / 1024);
284
                                minuts = (int)(minuts - (hours * 60));
285
                        }
286
                }
287
                StringBuffer s = new StringBuffer();
288
                if(hours != 0)
289
                        s.append(hours+" H ");
290
                if(minuts != 0)
291
                        s.append(minuts+" Min ");
292
                if(seconds != 0)
293
                        s.append(seconds+" Sec ");
294
                lTime.setText(s.toString());
295
        }
296
                
297
        /**
298
         *
299
         * @param comp
300
         */
301
        public void setCompression(boolean comp){
302
                if(comp)
303
                        lCompress.setText("Yes");
304
                else
305
                        lCompress.setText("No");
306
        }
307

    
308
}  //  @jve:decl-index=0:visual-constraint="10,10"