Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / extArcims / src / es / prodevelop / cit / gvsig / arcims / gui / panels / ImageServicePanel.java @ 20976

History | View | Annotate | Download (6.52 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop 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
 * For more information, contact:
20
 *
21
 *   Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43
package es.prodevelop.cit.gvsig.arcims.gui.panels;
44

    
45
import com.iver.andami.PluginServices;
46

    
47
import com.iver.utiles.swing.JComboBox;
48

    
49
import es.prodevelop.cit.gvsig.arcims.gui.panels.utils.ImageFormatSelector;
50
import es.prodevelop.cit.gvsig.arcims.gui.wizards.ArcImsWizard;
51

    
52
import org.gvsig.remoteClient.arcims.ArcImsClientP;
53
import org.gvsig.remoteClient.arcims.ArcImsImageClient;
54
import org.gvsig.remoteClient.arcims.ArcImsStatus;
55
import org.gvsig.remoteClient.arcims.exceptions.ArcImsException;
56
import org.gvsig.remoteClient.arcims.utils.ServiceInfoTags;
57

    
58
import java.awt.BorderLayout;
59
import java.awt.Point;
60
import java.awt.event.ActionEvent;
61

    
62
import javax.swing.JLabel;
63
import javax.swing.JPanel;
64
import javax.swing.plaf.basic.BasicArrowButton;
65

    
66

    
67
public class ImageServicePanel extends FeatureServicePanel {
68
    private static final long serialVersionUID = 0;
69
    private ImageFormatSelector formatSelector;
70

    
71
    // protected ImageFormatSelector imageFormatCombo;
72
    protected BasicArrowButton emergencyArrowButton;
73
    protected JPanel imageFormatPanel;
74
    private String imageFormat;
75

    
76
    public ImageServicePanel(ArcImsWizard parent, boolean prop) {
77
        super(parent, true, prop);
78
        imageFormat = ServiceInfoTags.vPNG8;
79
    }
80

    
81
    protected void addImageFormatPanel() {
82
        imageFormatPanel = new JPanel();
83
        imageFormatPanel.setBounds(180 - 6, 210 - 8, 287, 54); // hasta y = 264 
84
        imageFormatPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
85
                null, PluginServices.getText(this, "choose_image_format"),
86
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
87
                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
88

    
89
        formatSelector = new ImageFormatSelector();
90
        formatSelector.addListener(this);
91

    
92
        imageFormatPanel.setLayout(null);
93

    
94
        imgServiceTab_2.add(imageFormatPanel);
95
        imageFormatPanel.add(formatSelector); // setBounds(5, 15, 260, 20);
96
    }
97

    
98
    public void actionPerformed(ActionEvent e) {
99
        super.actionPerformed(e);
100

    
101
        if (e.getSource() == formatSelector) {
102
            imageFormat = formatSelector.getSelected();
103

    
104
            if (imageFormat.length() == 0) {
105
                return;
106
            }
107

    
108
            parentWizard.setImageFormat(captionToFormatInImageFormatCombo(
109
                    imageFormat));
110
        }
111
    }
112

    
113
    protected void updateWizardLayerQuery() {
114
        super.updateWizardLayerQuery();
115
        parentWizard.setImageFormat(getArcIMSImageFormat());
116
    }
117

    
118
    public String getComboImageFormat() {
119
        return imageFormat;
120
    }
121

    
122
    public String getArcIMSImageFormat() {
123
        return captionToFormatInImageFormatCombo(imageFormat);
124
    }
125

    
126
    public void loadImageFormatCombo(ArcImsImageClient client,
127
        ArcImsStatus tmpStatus) {
128
        try {
129
            formatSelector.setAllEnabled(false);
130

    
131
            if (client.testFromat(tmpStatus, ServiceInfoTags.vPNG8)) {
132
                formatSelector.setThisEnabled("PNG8");
133
                formatSelector.setSelected("PNG8");
134
            }
135

    
136
            if (client.testFromat(tmpStatus, ServiceInfoTags.vPNG24)) {
137
                formatSelector.setThisEnabled("PNG24");
138
                formatSelector.setSelected("PNG24");
139
            }
140

    
141
            if (client.testFromat(tmpStatus, ServiceInfoTags.vJPEG)) {
142
                formatSelector.setThisEnabled("JPG");
143
                formatSelector.setSelected("JPG");
144
            }
145

    
146
            if (client.testFromat(tmpStatus, ServiceInfoTags.vGIF)) {
147
                formatSelector.setThisEnabled("GIF");
148
                formatSelector.setSelected("GIF");
149
            }
150

    
151
            parentWizard.setImageFormat(ServiceInfoTags.vPNG8);
152
        }
153
        catch (ArcImsException e) {
154
            logger.error("While loading image formats combo ", e);
155
        }
156
    }
157

    
158
    public void setInImageFormatCombo(String imgFormat) {
159
        String caption = formatToCaptionInImageFormatCombo(imgFormat);
160
        formatSelector.setSelected(caption);
161
    }
162

    
163
    public void emptyFormatsCombo() {
164
        formatSelector.setAllEnabled(false);
165
    }
166

    
167
    public ImageFormatSelector getImageFormatCombo() {
168
        return formatSelector;
169
    }
170

    
171
    private String captionToFormatInImageFormatCombo(String caption) {
172
        String resp = "Unknown";
173

    
174
        if (caption.compareToIgnoreCase("JPG") == 0) {
175
            return ServiceInfoTags.vJPEG;
176
        }
177

    
178
        if (caption.compareToIgnoreCase("PNG8") == 0) {
179
            return ServiceInfoTags.vPNG8;
180
        }
181

    
182
        if (caption.compareToIgnoreCase("PNG24") == 0) {
183
            return ServiceInfoTags.vPNG24;
184
        }
185

    
186
        if (caption.compareToIgnoreCase("GIF") == 0) {
187
            return ServiceInfoTags.vGIF;
188
        }
189

    
190
        return resp;
191
    }
192

    
193
    private String formatToCaptionInImageFormatCombo(String format) {
194
        String resp = "Unknown";
195

    
196
        if (format.compareToIgnoreCase(ServiceInfoTags.vJPEG) == 0) {
197
            return "JPG";
198
        }
199

    
200
        if (format.compareToIgnoreCase(ServiceInfoTags.vPNG8) == 0) {
201
            return "PNG8";
202
        }
203

    
204
        if (format.compareToIgnoreCase(ServiceInfoTags.vPNG24) == 0) {
205
            return "PNG24";
206
        }
207

    
208
        if (format.compareToIgnoreCase(ServiceInfoTags.vGIF) == 0) {
209
            return "GIF";
210
        }
211

    
212
        return resp;
213
    }
214
}