Statistics
| Revision:

root / trunk / libraries / libUIComponent_praster / src / org / gvsig / gui / beans / graphic / BoxesPanel.java @ 8026

History | View | Annotate | Download (4.34 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.beans.graphic;
20

    
21
import java.awt.FlowLayout;
22

    
23
import javax.swing.JPanel;
24

    
25
import org.gvsig.gui.beans.textincreaser.TextIncreaserContainer;
26

    
27
/**
28
 * 
29
 * Nacho Brodin (brodin_ign@gva.es)
30
 */
31

    
32
public class BoxesPanel extends JPanel {
33
        
34
        private int                                 width = 300, height = 30;
35
        private JPanel pLeft = null;
36
        private JPanel pRight = null;
37
        private TextIncreaserContainer controlLeft = null;
38
        private TextIncreaserContainer controlRight = null;
39
        public BoxesPanel(int width, int height) {
40
                super();
41
                this.width = width;
42
                this.height = height;
43
                initialize(); 
44
        }
45

    
46
        /**
47
         * This method initializes this
48
         * 
49
         */
50
        private void initialize() {
51
        FlowLayout flowLayout = new FlowLayout();
52
        flowLayout.setHgap(0);
53
        flowLayout.setVgap(0);
54
        this.setLayout(flowLayout);
55
        this.setSize(new java.awt.Dimension(width, height));
56
        this.setPreferredSize(new java.awt.Dimension(width, height));
57
        this.add(getPLeft(), null);
58
        this.add(getPRight(), null);
59
                        
60
        }
61

    
62
        /**
63
         * This method initializes jPanel        
64
         *         
65
         * @return javax.swing.JPanel        
66
         */
67
        private JPanel getPLeft() {
68
                if (pLeft == null) {
69
                        FlowLayout flowLayout1 = new FlowLayout();
70
                        flowLayout1.setHgap(0);
71
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
72
                        flowLayout1.setVgap(0);
73
                        pLeft = new JPanel();
74
                        pLeft.setLayout(flowLayout1);
75
                        pLeft.add(getControlLeft(), null);
76
                        pLeft.setSize(new java.awt.Dimension(width >> 1, height));
77
                pLeft.setPreferredSize(new java.awt.Dimension(width >> 1, height));
78
                }
79
                return pLeft;
80
        }
81

    
82
        /**
83
         * This method initializes jPanel1        
84
         *         
85
         * @return javax.swing.JPanel        
86
         */
87
        private JPanel getPRight() {
88
                if (pRight == null) {
89
                        FlowLayout flowLayout2 = new FlowLayout();
90
                        flowLayout2.setHgap(0);
91
                        flowLayout2.setAlignment(java.awt.FlowLayout.RIGHT);
92
                        flowLayout2.setVgap(0);
93
                        pRight = new JPanel();
94
                        pRight.setLayout(flowLayout2);
95
                        pRight.add(getControlRight(), null);
96
                        pRight.setSize(new java.awt.Dimension(width >> 1, height));
97
                        pRight.setPreferredSize(new java.awt.Dimension(width >> 1, height));
98
                }
99
                return pRight;
100
        }
101

    
102
        /**
103
         * This method initializes jPanel        
104
         *         
105
         * @return javax.swing.JPanel        
106
         */
107
        public TextIncreaserContainer getControlLeft() {
108
                if (controlLeft == null) {
109
                        controlLeft = new TextIncreaserContainer(70, 0, 100, 0.0, true);
110
                }
111
                return controlLeft;
112
        }
113

    
114
        /**
115
         * This method initializes jPanel1        
116
         *         
117
         * @return javax.swing.JPanel        
118
         */
119
        public TextIncreaserContainer getControlRight() {
120
                if (controlRight == null) {
121
                        controlRight = new TextIncreaserContainer(70, 0, 100, 100.0, false);
122
                }
123
                return controlRight;
124
        }
125
        
126
        /**
127
         * Asigna el tama?o del componente
128
         * @param w Nuevo ancho del componente padre
129
         * @param h Nuevo alto del componente padre
130
         */
131
        public void setComponentSize(int w, int h){
132
                this.width = w;
133
                this.height = h;
134
                setSize(w, h);
135
                setPreferredSize(new java.awt.Dimension(w, h));
136
                getPRight().setSize(w >> 1, h);
137
                getPRight().setPreferredSize(new java.awt.Dimension(w >> 1, h));
138
                getPLeft().setSize(w >> 1, h);
139
                getPLeft().setPreferredSize(new java.awt.Dimension(w >> 1, h));
140
                
141
        }
142
        
143
        //****************************************************
144
        //M?TODOS DEL CONTROL
145
        
146
        /**
147
         * Obtiene el valor de los controles. 
148
         * @return Array con los valores de ambos controles. El primer valor del array es el control de la derecha
149
         * y el segundo el de la izquierda.  
150
         */
151
        public double[] getBoxesValues(){
152
                double[] v = new double[2];
153
                v[0] = getControlRight().getValue();
154
                v[1] = getControlLeft().getValue();
155
                return v;
156
        }
157
}