Statistics
| Revision:

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

History | View | Annotate | Download (4.41 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.Color;
22
import java.awt.FlowLayout;
23

    
24
import javax.swing.JLabel;
25
import javax.swing.JPanel;
26

    
27
import org.gvsig.gui.beans.graphic.listeners.GraphicListener;
28

    
29
/**
30
 * 
31
 * Nacho Brodin (brodin_ign@gva.es)
32
 */
33

    
34
public class DoubleSliderControlPanel extends JPanel {
35
        
36
        private int                                 width = 300, height = 25;
37
        private JLabel                                 lLeft = null;
38
        private JLabel                                 lRight = null;
39
        private GraphicListener         graphicListener = null;
40
        private JPanel pRight = null;
41
        private JPanel pLeft = null;
42
        
43
        public DoubleSliderControlPanel(int width, int height, GraphicListener         graphicListener) {
44
                super();
45
                this.width = width;
46
                this.height = height;
47
                this.graphicListener = graphicListener;
48
                initialize();
49
        }
50

    
51
        /**
52
         * This method initializes this
53
         * 
54
         */
55
        private void initialize() {
56
        FlowLayout flowLayout = new FlowLayout();
57
        flowLayout.setHgap(0);
58
        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
59
        flowLayout.setVgap(0);
60
        
61
        /*lRight = new JLabel();
62
        lRight.setForeground(Color.RED);
63
        lRight.setText("T");
64
        lRight.setPreferredSize(new java.awt.Dimension(15,25));
65
        
66
        lLeft = new JLabel();
67
        lLeft.setForeground(Color.BLUE);
68
        lLeft.setText("T");
69
        lLeft.setPreferredSize(new java.awt.Dimension(15,25));
70
        this.setLayout(flowLayout);
71
        
72
        lRight.addMouseListener(graphicListener);
73
        lRight.addMouseMotionListener(graphicListener);
74
        lLeft.addMouseListener(graphicListener);
75
        lLeft.addMouseMotionListener(graphicListener);
76
        graphicListener.setLabels(lLeft, lRight);*/
77
       
78
        this.setLayout(flowLayout);
79
        this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
80
        this.setSize(new java.awt.Dimension(width, height));
81
        this.setPreferredSize(new java.awt.Dimension(width, height));
82
  
83
        this.add(getPLeft(), null);
84
        this.add(getPRight(), null);
85
        graphicListener.setLabels(lLeft, lRight);
86
        
87
        //lLeft.setLocation(28, 4);
88
        //lRight.setLocation(470, 4);
89
        
90
        }
91

    
92
        /**
93
         * This method initializes jPanel        
94
         *         
95
         * @return javax.swing.JPanel        
96
         */
97
        private JPanel getPRight() {
98
                if (pRight == null) {
99
                        FlowLayout flowLayout1 = new FlowLayout();
100
                        flowLayout1.setHgap(0);
101
                        flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
102
                        flowLayout1.setVgap(0);
103
                        lRight = new JLabel();
104
                        lRight.setText("T");
105
                        lRight.setForeground(Color.RED);
106
                        lRight.setPreferredSize(new java.awt.Dimension(15,22));
107
                        pRight = new JPanel();
108
                        pRight.setLayout(flowLayout1);
109
                        pRight.setPreferredSize(new java.awt.Dimension((width >> 1) - 2,20));
110
                        pRight.setSize(width >> 1,20);
111
                        pRight.add(lRight, null);
112
                lRight.addMouseListener(graphicListener);
113
                lRight.addMouseMotionListener(graphicListener);
114
                }
115
                return pRight;
116
        }
117

    
118
        /**
119
         * This method initializes jPanel1        
120
         *         
121
         * @return javax.swing.JPanel        
122
         */
123
        private JPanel getPLeft() {
124
                if (pLeft == null) {
125
                        FlowLayout flowLayout1 = new FlowLayout();
126
                        flowLayout1.setHgap(28);
127
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
128
                        flowLayout1.setVgap(0);
129
                        lLeft = new JLabel();
130
                        lLeft.setText("T");
131
                        lLeft.setForeground(Color.BLUE);
132
                        lLeft.setPreferredSize(new java.awt.Dimension(15,22));
133
                        pLeft = new JPanel();
134
                        pLeft.setLayout(flowLayout1);
135
                        pLeft.setPreferredSize(new java.awt.Dimension((width >> 1) - 2,20));
136
                        pLeft.setSize(width >> 1,20);
137
                        pLeft.add(lLeft, null);
138
                        lLeft.addMouseListener(graphicListener);
139
                lLeft.addMouseMotionListener(graphicListener);
140
                }
141
                return pLeft;
142
        }
143

    
144
}