svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.image.extension / src / main / java / org / gvsig / arcims / image / gui / panels / utils / ImageFormatSelector.java @ 32321
History | View | Annotate | Download (4.61 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 Prodevelop S.L. main development
|
26 |
* http://www.prodevelop.es
|
27 |
*/
|
28 |
|
29 |
package org.gvsig.arcims.image.gui.panels.utils; |
30 |
|
31 |
import java.awt.event.ActionEvent; |
32 |
import java.awt.event.ActionListener; |
33 |
|
34 |
import javax.swing.ButtonGroup; |
35 |
import javax.swing.JPanel; |
36 |
import javax.swing.JRadioButton; |
37 |
import javax.swing.event.ChangeEvent; |
38 |
import javax.swing.event.ChangeListener; |
39 |
|
40 |
import org.gvsig.arcims.image.gui.panels.ImageServicePanel; |
41 |
|
42 |
|
43 |
|
44 |
public class ImageFormatSelector extends JPanel implements ChangeListener { |
45 |
private JRadioButton jpgRB; |
46 |
private JRadioButton gifRB; |
47 |
private JRadioButton png8RB; |
48 |
private JRadioButton png24RB; |
49 |
private ButtonGroup formatBG; |
50 |
private ActionListener listener; |
51 |
|
52 |
public ImageFormatSelector() {
|
53 |
jpgRB = new JRadioButton("JPG", true); |
54 |
jpgRB.addChangeListener(this);
|
55 |
jpgRB.setBounds(10, 0, 60, 20); |
56 |
|
57 |
gifRB = new JRadioButton("GIF", false); |
58 |
gifRB.addChangeListener(this);
|
59 |
gifRB.setBounds(70, 0, 60, 20); |
60 |
|
61 |
png8RB = new JRadioButton("PNG8", false); |
62 |
png8RB.addChangeListener(this);
|
63 |
png8RB.setBounds(130, 0, 60, 20); |
64 |
|
65 |
png24RB = new JRadioButton("PNG24", false); |
66 |
png24RB.addChangeListener(this);
|
67 |
png24RB.setBounds(190, 0, 60, 20); // llega hasta 10 + 4 * 60 = 250 |
68 |
|
69 |
formatBG = new ButtonGroup(); |
70 |
|
71 |
formatBG.add(jpgRB); |
72 |
formatBG.add(gifRB); |
73 |
formatBG.add(png8RB); |
74 |
formatBG.add(png24RB); |
75 |
|
76 |
setLayout(null);
|
77 |
setBounds(15, 23, 260, 20); |
78 |
|
79 |
add(jpgRB); |
80 |
add(gifRB); |
81 |
add(png8RB); |
82 |
add(png24RB); |
83 |
} |
84 |
|
85 |
public void setSelected(String format) { |
86 |
setAll(false);
|
87 |
|
88 |
if (format.compareToIgnoreCase(jpgRB.getText()) == 0) { |
89 |
jpgRB.setSelected(true);
|
90 |
} |
91 |
|
92 |
if (format.compareToIgnoreCase(gifRB.getText()) == 0) { |
93 |
gifRB.setSelected(true);
|
94 |
} |
95 |
|
96 |
if (format.compareToIgnoreCase(png8RB.getText()) == 0) { |
97 |
png8RB.setSelected(true);
|
98 |
} |
99 |
|
100 |
if (format.compareToIgnoreCase(png24RB.getText()) == 0) { |
101 |
png24RB.setSelected(true);
|
102 |
} |
103 |
} |
104 |
|
105 |
public String getSelected() { |
106 |
if (jpgRB.isSelected()) {
|
107 |
return jpgRB.getText();
|
108 |
} |
109 |
|
110 |
if (gifRB.isSelected()) {
|
111 |
return gifRB.getText();
|
112 |
} |
113 |
|
114 |
if (png8RB.isSelected()) {
|
115 |
return png8RB.getText();
|
116 |
} |
117 |
|
118 |
if (png24RB.isSelected()) {
|
119 |
return png24RB.getText();
|
120 |
} |
121 |
|
122 |
return ""; |
123 |
} |
124 |
|
125 |
private void setAll(boolean selected) { |
126 |
jpgRB.setSelected(selected); |
127 |
gifRB.setSelected(selected); |
128 |
png8RB.setSelected(selected); |
129 |
png24RB.setSelected(selected); |
130 |
} |
131 |
|
132 |
public void setAllEnabled(boolean enabled) { |
133 |
jpgRB.setEnabled(enabled); |
134 |
gifRB.setEnabled(enabled); |
135 |
png8RB.setEnabled(enabled); |
136 |
png24RB.setEnabled(enabled); |
137 |
} |
138 |
|
139 |
public void setThisEnabled(String format) { |
140 |
if (format.compareToIgnoreCase(jpgRB.getText()) == 0) { |
141 |
jpgRB.setEnabled(true);
|
142 |
} |
143 |
|
144 |
if (format.compareToIgnoreCase(gifRB.getText()) == 0) { |
145 |
gifRB.setEnabled(true);
|
146 |
} |
147 |
|
148 |
if (format.compareToIgnoreCase(png8RB.getText()) == 0) { |
149 |
png8RB.setEnabled(true);
|
150 |
} |
151 |
|
152 |
if (format.compareToIgnoreCase(png24RB.getText()) == 0) { |
153 |
png24RB.setEnabled(true);
|
154 |
} |
155 |
} |
156 |
|
157 |
public void addListener(ImageServicePanel panel) { |
158 |
listener = panel; |
159 |
} |
160 |
|
161 |
public void stateChanged(ChangeEvent arg0) { |
162 |
if (listener != null) { |
163 |
ActionEvent ae = new ActionEvent(this, |
164 |
ActionEvent.ACTION_PERFORMED, ""); |
165 |
listener.actionPerformed(ae); |
166 |
} |
167 |
} |
168 |
} |