svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / vectorialdb / visibility / VisibilityScaleSelector.java @ 45160
History | View | Annotate | Download (6.15 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2017 gvSIG Association
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.geodb.vectorialdb.visibility; |
24 |
|
25 |
import java.awt.event.ActionEvent; |
26 |
import java.awt.event.ActionListener; |
27 |
import java.util.Locale; |
28 |
import org.gvsig.geodb.WizardDBVectorial; |
29 |
|
30 |
|
31 |
import org.slf4j.Logger; |
32 |
import org.slf4j.LoggerFactory; |
33 |
|
34 |
import org.gvsig.tools.ToolsLocator; |
35 |
import org.gvsig.tools.i18n.I18nManager; |
36 |
|
37 |
|
38 |
/**
|
39 |
* @author fdiaz
|
40 |
*
|
41 |
*/
|
42 |
public class VisibilityScaleSelector extends VisibilityScaleSelectorView { |
43 |
|
44 |
private static final Logger LOG = LoggerFactory.getLogger(VisibilityScaleSelector.class); |
45 |
|
46 |
private static final int SCALE_ABOVE_DENOMINATOR_1_1000 = 2000; |
47 |
private static final int SCALE_BELOW_DENOMINATOR_1_1000 = 1; |
48 |
|
49 |
private static final int SCALE_ABOVE_DENOMINATOR_1_5000 = 8000; |
50 |
private static final int SCALE_BELOW_DENOMINATOR_1_5000 = 1; |
51 |
|
52 |
private static final int SCALE_ABOVE_DENOMINATOR_1_25000 = 40000; |
53 |
private static final int SCALE_BELOW_DENOMINATOR_1_25000 = 1; |
54 |
|
55 |
private boolean okPressed = false; |
56 |
|
57 |
|
58 |
/**
|
59 |
*
|
60 |
*/
|
61 |
public VisibilityScaleSelector() {
|
62 |
super();
|
63 |
init(); |
64 |
initializeComponents(); |
65 |
translate(); |
66 |
} |
67 |
|
68 |
/**
|
69 |
* This method initializes this
|
70 |
*
|
71 |
* @return void
|
72 |
*/
|
73 |
private void init() { |
74 |
btnAccept.addActionListener((java.awt.event.ActionEvent e) -> { |
75 |
closeWindow(); |
76 |
okPressed = true;
|
77 |
}); |
78 |
btnCancel.addActionListener((java.awt.event.ActionEvent e) -> { |
79 |
closeWindow(); |
80 |
okPressed = false;
|
81 |
}); |
82 |
} |
83 |
|
84 |
private void initializeComponents() { |
85 |
|
86 |
rdb1_1000.addActionListener(new ActionListener() { |
87 |
@Override
|
88 |
public void actionPerformed(ActionEvent e) { |
89 |
txtScaleAboveDenominator.setValue(SCALE_ABOVE_DENOMINATOR_1_1000); |
90 |
txtScaleBelowDenominator.setValue(SCALE_BELOW_DENOMINATOR_1_1000); |
91 |
} |
92 |
}); |
93 |
|
94 |
rdb1_5000.addActionListener(new ActionListener() { |
95 |
@Override
|
96 |
public void actionPerformed(ActionEvent e) { |
97 |
txtScaleAboveDenominator.setValue(SCALE_ABOVE_DENOMINATOR_1_5000); |
98 |
txtScaleBelowDenominator.setValue(SCALE_BELOW_DENOMINATOR_1_5000); |
99 |
} |
100 |
}); |
101 |
|
102 |
rdb1_25000.addActionListener(new ActionListener() { |
103 |
@Override
|
104 |
public void actionPerformed(ActionEvent e) { |
105 |
txtScaleAboveDenominator.setValue(SCALE_ABOVE_DENOMINATOR_1_25000); |
106 |
txtScaleBelowDenominator.setValue(SCALE_BELOW_DENOMINATOR_1_25000); |
107 |
} |
108 |
}); |
109 |
|
110 |
|
111 |
} |
112 |
|
113 |
private void translate() { |
114 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
115 |
String value = String.valueOf(WizardDBVectorial.NUMBER_OF_FEATURES_TO_ASK_FOR_VISIBILITY_SCALE); |
116 |
lblDescription.setText(i18nManager.getTranslation(lblDescription.getText(),new String[]{value})); |
117 |
lbl_1_25000_description.setText(i18nManager.getTranslation(lbl_1_25000_description.getText())); |
118 |
lbl_1_5000_description.setText(i18nManager.getTranslation(lbl_1_5000_description.getText())); |
119 |
lbl_1_1000_description.setText(i18nManager.getTranslation(lbl_1_1000_description.getText())); |
120 |
rdbConditions.setText(i18nManager.getTranslation(rdbConditions.getText())); |
121 |
lblBelow.setText(i18nManager.getTranslation(lblBelow.getText())); |
122 |
lblAbove.setText(i18nManager.getTranslation(lblAbove.getText())); |
123 |
lblMaximumScale.setText(i18nManager.getTranslation(lblMaximumScale.getText())); |
124 |
lblMinimumScale.setText(i18nManager.getTranslation(lblMinimumScale.getText())); |
125 |
chkRememberAnswer.setText(i18nManager.getTranslation(chkRememberAnswer.getText())); |
126 |
btnAccept.setText(i18nManager.getTranslation(btnAccept.getText())); |
127 |
btnCancel.setText(i18nManager.getTranslation(btnCancel.getText())); |
128 |
|
129 |
} |
130 |
|
131 |
/**
|
132 |
* @param locale
|
133 |
*
|
134 |
*/
|
135 |
public void setLocate(Locale locale) { |
136 |
Locale l = super.getLocale(); |
137 |
if (!l.equals(locale)) {
|
138 |
translate(); |
139 |
} |
140 |
super.setLocale(locale);
|
141 |
} |
142 |
|
143 |
public int getScaleAboveDenominator(){ |
144 |
if(rdb1_1000.isSelected()){
|
145 |
return SCALE_ABOVE_DENOMINATOR_1_1000;
|
146 |
} |
147 |
if(rdb1_5000.isSelected()){
|
148 |
return SCALE_ABOVE_DENOMINATOR_1_5000;
|
149 |
} |
150 |
if(rdb1_25000.isSelected()){
|
151 |
return SCALE_ABOVE_DENOMINATOR_1_25000;
|
152 |
} |
153 |
if(rdbConditions.isSelected()){
|
154 |
return ((Number)txtScaleAboveDenominator.getValue()).intValue(); |
155 |
} |
156 |
return Integer.MAX_VALUE; |
157 |
} |
158 |
|
159 |
public int getScaleBelowDenominator(){ |
160 |
if(rdb1_1000.isSelected()){
|
161 |
return SCALE_BELOW_DENOMINATOR_1_1000;
|
162 |
} |
163 |
if(rdb1_5000.isSelected()){
|
164 |
return SCALE_BELOW_DENOMINATOR_1_5000;
|
165 |
} |
166 |
if(rdb1_25000.isSelected()){
|
167 |
return SCALE_BELOW_DENOMINATOR_1_25000;
|
168 |
} |
169 |
if(rdbConditions.isSelected()){
|
170 |
return ((Number)txtScaleBelowDenominator.getValue()).intValue(); |
171 |
} |
172 |
return 1; |
173 |
} |
174 |
|
175 |
public boolean getRememberAnswer() { |
176 |
return chkRememberAnswer.isSelected();
|
177 |
} |
178 |
|
179 |
public void closeWindow() { |
180 |
this.setVisible(false); |
181 |
} |
182 |
|
183 |
public boolean isOkPressed() { |
184 |
return okPressed;
|
185 |
} |
186 |
|
187 |
} |