root / trunk / extensions / extArcims / src / es / prodevelop / cit / gvsig / arcims / gui / panels / ImageServicePanel.java @ 8110
History | View | Annotate | Download (4.45 KB)
1 |
package es.prodevelop.cit.gvsig.arcims.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Point; |
5 |
import java.awt.event.ActionEvent; |
6 |
|
7 |
import javax.swing.JLabel; |
8 |
import javax.swing.JPanel; |
9 |
import javax.swing.plaf.basic.BasicArrowButton; |
10 |
|
11 |
import org.gvsig.remoteClient.arcims.ArcImsClientP; |
12 |
import org.gvsig.remoteClient.arcims.ArcImsImageClient; |
13 |
import org.gvsig.remoteClient.arcims.ArcImsStatus; |
14 |
import org.gvsig.remoteClient.arcims.exceptions.ArcImsException; |
15 |
import org.gvsig.remoteClient.arcims.utils.ServiceInfoTags; |
16 |
|
17 |
import com.iver.andami.PluginServices; |
18 |
import com.iver.utiles.swing.JComboBox; |
19 |
|
20 |
import es.prodevelop.cit.gvsig.arcims.gui.panels.utils.ImageFormatSelector; |
21 |
import es.prodevelop.cit.gvsig.arcims.gui.wizards.ArcImsWizard; |
22 |
|
23 |
public class ImageServicePanel extends FeatureServicePanel { |
24 |
|
25 |
private static final long serialVersionUID = 0; |
26 |
|
27 |
private ImageFormatSelector formatSelector;
|
28 |
// protected ImageFormatSelector imageFormatCombo;
|
29 |
|
30 |
protected BasicArrowButton emergencyArrowButton; |
31 |
protected JPanel imageFormatPanel; |
32 |
|
33 |
private String imageFormat; |
34 |
|
35 |
public ImageServicePanel(ArcImsWizard parent, boolean prop) { |
36 |
super(parent, true, prop); |
37 |
imageFormat = ServiceInfoTags.vPNG8; |
38 |
} |
39 |
|
40 |
protected void addImageFormatPanel() { |
41 |
|
42 |
imageFormatPanel = new JPanel(); |
43 |
imageFormatPanel.setBounds(180 - 6, 210 - 8, 287, 54); // hasta y = 264 |
44 |
imageFormatPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
45 |
null, PluginServices.getText(this, "choose_image_format"), |
46 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
47 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, |
48 |
null, null)); |
49 |
|
50 |
|
51 |
formatSelector = new ImageFormatSelector();
|
52 |
formatSelector.addListener(this);
|
53 |
|
54 |
imageFormatPanel.setLayout(null);
|
55 |
|
56 |
imgServiceTab_2.add(imageFormatPanel); |
57 |
imageFormatPanel.add(formatSelector); // setBounds(5, 15, 260, 20);
|
58 |
} |
59 |
|
60 |
public void actionPerformed(ActionEvent e) { |
61 |
super.actionPerformed(e);
|
62 |
|
63 |
if (e.getSource() == formatSelector) {
|
64 |
imageFormat = formatSelector.getSelected(); |
65 |
if (imageFormat.length() == 0) { |
66 |
return;
|
67 |
} |
68 |
parentWizard.setImageFormat(captionToFormatInImageFormatCombo(imageFormat)); |
69 |
} |
70 |
|
71 |
} |
72 |
|
73 |
protected void updateWizardLayerQuery() { |
74 |
super.updateWizardLayerQuery();
|
75 |
System.err.println("Image - updateWizardLayerQuery()"); |
76 |
parentWizard.setImageFormat(getImageFormat()); |
77 |
} |
78 |
|
79 |
public String getImageFormat() { |
80 |
return imageFormat;
|
81 |
} |
82 |
|
83 |
public void loadImageFormatCombo(ArcImsImageClient client, ArcImsStatus tmpStatus) { |
84 |
try {
|
85 |
formatSelector.setAllEnabled(false);
|
86 |
|
87 |
if (client.testFromat(tmpStatus, ServiceInfoTags.vPNG8)) {
|
88 |
formatSelector.setThisEnabled("PNG8");
|
89 |
formatSelector.setSelected("PNG8");
|
90 |
} |
91 |
|
92 |
if (client.testFromat(tmpStatus, ServiceInfoTags.vPNG24)) {
|
93 |
formatSelector.setThisEnabled("PNG24");
|
94 |
formatSelector.setSelected("PNG24");
|
95 |
} |
96 |
|
97 |
if (client.testFromat(tmpStatus, ServiceInfoTags.vJPEG)) {
|
98 |
formatSelector.setThisEnabled("JPG");
|
99 |
formatSelector.setSelected("JPG");
|
100 |
} |
101 |
|
102 |
if (client.testFromat(tmpStatus, ServiceInfoTags.vGIF)) {
|
103 |
formatSelector.setThisEnabled("GIF");
|
104 |
formatSelector.setSelected("GIF");
|
105 |
} |
106 |
|
107 |
parentWizard.setImageFormat(ServiceInfoTags.vPNG8); |
108 |
} catch (ArcImsException e) {
|
109 |
logger.error("While loading image formats combo ", e);
|
110 |
} |
111 |
} |
112 |
|
113 |
public void setInImageFormatCombo(String imgFormat) { |
114 |
String caption = formatToCaptionInImageFormatCombo(imgFormat);
|
115 |
formatSelector.setSelected(caption); |
116 |
} |
117 |
|
118 |
public void emptyFormatsCombo() { |
119 |
formatSelector.setAllEnabled(false);
|
120 |
} |
121 |
|
122 |
public ImageFormatSelector getImageFormatCombo() {
|
123 |
return formatSelector;
|
124 |
} |
125 |
|
126 |
private String captionToFormatInImageFormatCombo(String caption) { |
127 |
String resp = "Unknown"; |
128 |
if (caption.compareToIgnoreCase("JPG") == 0) { return ServiceInfoTags.vJPEG; } |
129 |
if (caption.compareToIgnoreCase("PNG8") == 0) { return ServiceInfoTags.vPNG8; } |
130 |
if (caption.compareToIgnoreCase("PNG24") == 0) { return ServiceInfoTags.vPNG24; } |
131 |
if (caption.compareToIgnoreCase("GIF") == 0) { return ServiceInfoTags.vGIF; } |
132 |
return resp;
|
133 |
} |
134 |
|
135 |
private String formatToCaptionInImageFormatCombo(String format) { |
136 |
String resp = "Unknown"; |
137 |
if (format.compareToIgnoreCase(ServiceInfoTags.vJPEG) == 0) { return "JPG"; } |
138 |
if (format.compareToIgnoreCase(ServiceInfoTags.vPNG8) == 0) { return "PNG8"; } |
139 |
if (format.compareToIgnoreCase(ServiceInfoTags.vPNG24) == 0) { return "PNG24"; } |
140 |
if (format.compareToIgnoreCase(ServiceInfoTags.vGIF) == 0) { return "GIF"; } |
141 |
return resp;
|
142 |
} |
143 |
|
144 |
|
145 |
|
146 |
|
147 |
} |