Statistics
| Revision:

svn-gvsig-desktop / tags / v1_11_0_Build_1306 / extensions / extArcims / src / es / prodevelop / cit / gvsig / arcims / gui / panels / ImageServicePanel.java @ 35731

History | View | Annotate | Download (6.35 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 java.awt.event.ActionEvent;
46

    
47
import javax.swing.JPanel;
48
import javax.swing.plaf.basic.BasicArrowButton;
49

    
50
import org.gvsig.remoteClient.arcims.ArcImsImageClient;
51
import org.gvsig.remoteClient.arcims.ArcImsStatus;
52
import org.gvsig.remoteClient.arcims.exceptions.ArcImsException;
53
import org.gvsig.remoteClient.arcims.utils.ServiceInfoTags;
54

    
55
import com.iver.andami.PluginServices;
56

    
57
import es.prodevelop.cit.gvsig.arcims.gui.panels.utils.ImageFormatSelector;
58
import es.prodevelop.cit.gvsig.arcims.gui.wizards.ArcImsWizard;
59

    
60

    
61
public class ImageServicePanel extends FeatureServicePanel {
62
    private static final long serialVersionUID = 0;
63
    private ImageFormatSelector formatSelector;
64

    
65
    // protected ImageFormatSelector imageFormatCombo;
66
    protected BasicArrowButton emergencyArrowButton;
67
    protected JPanel imageFormatPanel;
68
    private String imageFormat;
69

    
70
    public ImageServicePanel(ArcImsWizard parent, boolean prop) {
71
        super(parent, true, prop);
72
        imageFormat = ServiceInfoTags.vPNG8;
73
    }
74

    
75
    protected void addImageFormatPanel() {
76
        imageFormatPanel = new JPanel();
77
        imageFormatPanel.setBounds(180 - 6, 210 - 8, 287, 54); // hasta y = 264 
78
        imageFormatPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
79
                null, PluginServices.getText(this, "choose_image_format"),
80
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
81
                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
82

    
83
        formatSelector = new ImageFormatSelector();
84
        formatSelector.addListener(this);
85

    
86
        imageFormatPanel.setLayout(null);
87

    
88
        imgServiceTab_2.add(imageFormatPanel);
89
        imageFormatPanel.add(formatSelector); // setBounds(5, 15, 260, 20);
90
    }
91

    
92
    public void actionPerformed(ActionEvent e) {
93
        super.actionPerformed(e);
94

    
95
        if (e.getSource() == formatSelector) {
96
            imageFormat = formatSelector.getSelected();
97

    
98
            if (imageFormat.length() == 0) {
99
                return;
100
            }
101

    
102
            parentWizard.setImageFormat(captionToFormatInImageFormatCombo(
103
                    imageFormat));
104
        }
105
    }
106

    
107
    protected void updateWizardLayerQuery() {
108
        super.updateWizardLayerQuery();
109
        parentWizard.setImageFormat(getArcIMSImageFormat());
110
    }
111

    
112
    public String getComboImageFormat() {
113
        return imageFormat;
114
    }
115

    
116
    public String getArcIMSImageFormat() {
117
        return captionToFormatInImageFormatCombo(imageFormat);
118
    }
119

    
120
    public void loadImageFormatCombo(ArcImsImageClient client,
121
        ArcImsStatus tmpStatus) {
122
        try {
123
            formatSelector.setAllEnabled(false);
124

    
125
            if (client.testFromat(tmpStatus, ServiceInfoTags.vPNG8)) {
126
                formatSelector.setThisEnabled("PNG8");
127
                formatSelector.setSelected("PNG8");
128
            }
129

    
130
            if (client.testFromat(tmpStatus, ServiceInfoTags.vPNG24)) {
131
                formatSelector.setThisEnabled("PNG24");
132
                formatSelector.setSelected("PNG24");
133
            }
134

    
135
            if (client.testFromat(tmpStatus, ServiceInfoTags.vJPEG)) {
136
                formatSelector.setThisEnabled("JPG");
137
                formatSelector.setSelected("JPG");
138
            }
139

    
140
            if (client.testFromat(tmpStatus, ServiceInfoTags.vGIF)) {
141
                formatSelector.setThisEnabled("GIF");
142
                formatSelector.setSelected("GIF");
143
            }
144

    
145
            parentWizard.setImageFormat(ServiceInfoTags.vPNG8);
146
        }
147
        catch (ArcImsException e) {
148
            logger.error("While loading image formats combo ", e);
149
        }
150
    }
151

    
152
    public void setInImageFormatCombo(String imgFormat) {
153
        String caption = formatToCaptionInImageFormatCombo(imgFormat);
154
        formatSelector.setSelected(caption);
155
    }
156

    
157
    public void emptyFormatsCombo() {
158
        formatSelector.setAllEnabled(false);
159
    }
160

    
161
    public ImageFormatSelector getImageFormatCombo() {
162
        return formatSelector;
163
    }
164

    
165
    private String captionToFormatInImageFormatCombo(String caption) {
166
        String resp = "Unknown";
167

    
168
        if (caption.compareToIgnoreCase("JPG") == 0) {
169
            return ServiceInfoTags.vJPEG;
170
        }
171

    
172
        if (caption.compareToIgnoreCase("PNG8") == 0) {
173
            return ServiceInfoTags.vPNG8;
174
        }
175

    
176
        if (caption.compareToIgnoreCase("PNG24") == 0) {
177
            return ServiceInfoTags.vPNG24;
178
        }
179

    
180
        if (caption.compareToIgnoreCase("GIF") == 0) {
181
            return ServiceInfoTags.vGIF;
182
        }
183

    
184
        return resp;
185
    }
186

    
187
    private String formatToCaptionInImageFormatCombo(String format) {
188
        String resp = "Unknown";
189

    
190
        if (format.compareToIgnoreCase(ServiceInfoTags.vJPEG) == 0) {
191
            return "JPG";
192
        }
193

    
194
        if (format.compareToIgnoreCase(ServiceInfoTags.vPNG8) == 0) {
195
            return "PNG8";
196
        }
197

    
198
        if (format.compareToIgnoreCase(ServiceInfoTags.vPNG24) == 0) {
199
            return "PNG24";
200
        }
201

    
202
        if (format.compareToIgnoreCase(ServiceInfoTags.vGIF) == 0) {
203
            return "GIF";
204
        }
205

    
206
        return resp;
207
    }
208
}