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 4480 nacho
package com.iver.cit.gvsig.rasterTools.saveRaster.ui.info;
2
3 4486 nacho
import java.awt.Dimension;
4
import java.awt.FlowLayout;
5
import java.awt.GridBagConstraints;
6 4480 nacho
import java.awt.GridBagLayout;
7 4486 nacho
8
import javax.swing.JButton;
9 4480 nacho
import javax.swing.JLabel;
10 4486 nacho
import javax.swing.JPanel;
11 4480 nacho
12
public class EndInfoPanel extends JPanel {
13
14
        private JPanel pFile = null;
15
        private JPanel pTime = null;
16
        private JPanel pButtons = null;
17 4486 nacho
        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 4480 nacho
        private JPanel jPanel = null;
27 4486 nacho
        private JPanel pMain = null;
28 4499 nacho
        private JLabel lFile = null;
29 4480 nacho
        /**
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 4486 nacho
                GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
44
                gridBagConstraints4.gridx = 0;
45
                gridBagConstraints4.gridy = 0;
46 4480 nacho
                GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
47
                gridBagConstraints2.gridx = 0;
48 4486 nacho
                gridBagConstraints2.gridy = 1;
49 4480 nacho
                this.setLayout(new GridBagLayout());
50 4532 nacho
                this.setSize(482, 130);
51
                this.setPreferredSize(new java.awt.Dimension(472,75));
52 4486 nacho
                this.add(getJPanel12(), gridBagConstraints4);
53 4480 nacho
                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 4499 nacho
                        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 4480 nacho
                        FlowLayout flowLayout = new FlowLayout();
68
                        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
69 4499 nacho
                        flowLayout.setHgap(5);
70 4480 nacho
                        pFile = new JPanel();
71
                        pFile.setLayout(flowLayout);
72
                        pFile.setPreferredSize(new java.awt.Dimension(472,25));
73 4486 nacho
                        lFileNameTag = new JLabel();
74
                        lFileNameTag.setText("File:");
75
                        pFile.add(lFileNameTag, null);
76 4499 nacho
                        pFile.add(lFile, null);
77 4480 nacho
                }
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 4486 nacho
                        lTime = new JLabel();
89
                        lTime.setText("");
90 4499 nacho
                        lTime.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
91
                        lTime.setPreferredSize(new java.awt.Dimension(170,15));
92 4486 nacho
                        lSizeTag = new JLabel();
93
                        lSizeTag.setText("Size: ");
94 4480 nacho
                        FlowLayout flowLayout1 = new FlowLayout();
95
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
96 4499 nacho
                        flowLayout1.setHgap(5);
97 4486 nacho
                        lSize = new JLabel();
98
                        lSize.setText("");
99 4499 nacho
                        lSize.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
100
                        lSize.setPreferredSize(new java.awt.Dimension(170,15));
101 4486 nacho
                        lTimeTag = new JLabel();
102
                        lTimeTag.setText("Time:");
103 4480 nacho
                        pTime = new JPanel();
104
                        pTime.setLayout(flowLayout1);
105
                        pTime.setPreferredSize(new java.awt.Dimension(472,25));
106 4486 nacho
                        pTime.add(lTimeTag, null);
107
                        pTime.add(lTime, null);
108
                        pTime.add(lSizeTag, null);
109
                        pTime.add(lSize, null);
110 4480 nacho
                }
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 4486 nacho
                        pButtons.add(getBAccept(), null);
128 4480 nacho
                }
129
                return pButtons;
130
        }
131
132
        /**
133
         * This method initializes jButton
134
         *
135
         * @return javax.swing.JButton
136
         */
137 4486 nacho
        public JButton getBAccept() {
138 4480 nacho
                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 4486 nacho
                if (pCompression == null) {
152
                        FlowLayout flowLayout3 = new FlowLayout();
153
                        flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
154 4499 nacho
                        flowLayout3.setHgap(5);
155 4486 nacho
                        lCompress = new JLabel();
156
                        lCompress.setText("");
157 4499 nacho
                        lCompress.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
158 4486 nacho
                        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 4480 nacho
                if (jPanel == null) {
177
                        jPanel = new JPanel();
178 4532 nacho
                        jPanel.setPreferredSize(new java.awt.Dimension(472,0));
179 4480 nacho
                }
180
                return jPanel;
181
        }
182 4486 nacho
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 4532 nacho
                        pMain.setPreferredSize(new java.awt.Dimension(482,100));
206 4486 nacho
                        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 4480 nacho
216 4486 nacho
        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 4499 nacho
                lFile.setText(fileName);
238 4486 nacho
        }
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 4499 nacho
                int bytes = (int)size, kBytes = 0, mBytes = 0, gBytes = 0;
248
                if(size >= 1024){
249 4486 nacho
                        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 4499 nacho
                int days = 0, hours = 0, minuts = 0, seconds = (int)(time / 1000D);
279
                if(seconds >= 60){
280 4532 nacho
                        minuts = (int)(seconds / 60);
281
                        seconds = (int)(seconds - (minuts * 60));
282 4486 nacho
                        if(minuts >= 60){
283
                                hours = (int)(minuts / 1024);
284 4499 nacho
                                minuts = (int)(minuts - (hours * 60));
285 4486 nacho
                        }
286
                }
287
                StringBuffer s = new StringBuffer();
288
                if(hours != 0)
289
                        s.append(hours+" H ");
290
                if(minuts != 0)
291 4499 nacho
                        s.append(minuts+" Min ");
292 4486 nacho
                if(seconds != 0)
293 4499 nacho
                        s.append(seconds+" Sec ");
294 4486 nacho
                lTime.setText(s.toString());
295
        }
296
297 4499 nacho
        /**
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 4486 nacho
308 4480 nacho
}  //  @jve:decl-index=0:visual-constraint="10,10"