svn-gvsig-desktop / branches / v10 / extensions / extAnnotations / src / com / iver / cit / gvsig / project / documents / view / tool / gui / Annotation_ModifyWindow.java @ 11743
History | View | Annotate | Download (11.5 KB)
1 |
package com.iver.cit.gvsig.project.documents.view.tool.gui; |
---|---|
2 |
|
3 |
import javax.swing.JComboBox; |
4 |
import javax.swing.JPanel; |
5 |
|
6 |
import com.hardcode.gdbms.engine.values.NumericValue; |
7 |
import com.hardcode.gdbms.engine.values.StringValue; |
8 |
import com.hardcode.gdbms.engine.values.Value; |
9 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
10 |
import com.iver.andami.PluginServices; |
11 |
import com.iver.andami.ui.mdiManager.IWindow; |
12 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
13 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Mapping; |
14 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
15 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
16 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
17 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameTextDialog; |
18 |
|
19 |
import java.awt.BorderLayout; |
20 |
import java.awt.Color; |
21 |
import java.awt.Font; |
22 |
import java.awt.GridBagLayout; |
23 |
import javax.swing.JLabel; |
24 |
import java.awt.GridBagConstraints; |
25 |
import java.awt.event.ActionListener; |
26 |
|
27 |
import javax.swing.JTextField; |
28 |
import javax.swing.text.StyleConstants; |
29 |
|
30 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
31 |
|
32 |
public class Annotation_ModifyWindow extends JPanel implements IWindow{ |
33 |
|
34 |
private JPanel jPanel = null; |
35 |
private JLabel jLabel = null; |
36 |
private JTextField jTextField = null; |
37 |
private JLabel jLabel1 = null; |
38 |
private JComboBox cmbTypeFont = null; |
39 |
private JLabel jLabel2 = null; |
40 |
private JComboBox cmbStyleFont = null; |
41 |
private JLabel jLabel3 = null; |
42 |
private JTextField txtHeight = null; |
43 |
private JLabel jLabel4 = null; |
44 |
private ColorChooserPanel colorPanel = null; |
45 |
private JLabel jLabel5 = null; |
46 |
private JTextField txtRotate = null; |
47 |
private AcceptCancelPanel accept;
|
48 |
private boolean isAccepted=false; |
49 |
private JPanel jPanel1 = null; // @jve:decl-index=0:visual-constraint="10,10" |
50 |
private JPanel jPanel2 = null; |
51 |
private Annotation_Mapping mapping;
|
52 |
/**
|
53 |
* This is the default constructor
|
54 |
*/
|
55 |
public Annotation_ModifyWindow() {
|
56 |
super();
|
57 |
initialize(); |
58 |
} |
59 |
|
60 |
/**
|
61 |
* This method initializes this
|
62 |
*
|
63 |
* @return void
|
64 |
*/
|
65 |
private void initialize() { |
66 |
this.setLayout(new BorderLayout()); |
67 |
this.setSize(292, 197); |
68 |
this.add(getJPanel1(), java.awt.BorderLayout.CENTER);
|
69 |
} |
70 |
|
71 |
public WindowInfo getWindowInfo() {
|
72 |
WindowInfo wi=new WindowInfo(WindowInfo.MODALDIALOG);
|
73 |
wi.setTitle(PluginServices.getText(this,"modify_annotation")); |
74 |
return wi;
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* This method initializes jPanel
|
79 |
*
|
80 |
* @return javax.swing.JPanel
|
81 |
*/
|
82 |
private JPanel getJPanel() { |
83 |
if (jPanel == null) { |
84 |
GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
85 |
gridBagConstraints11.fill = java.awt.GridBagConstraints.HORIZONTAL; |
86 |
gridBagConstraints11.gridy = 5;
|
87 |
gridBagConstraints11.weightx = 1.0;
|
88 |
gridBagConstraints11.gridx = 1;
|
89 |
GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); |
90 |
gridBagConstraints10.gridx = 0;
|
91 |
gridBagConstraints10.gridy = 5;
|
92 |
jLabel5 = new JLabel(); |
93 |
jLabel5.setText(PluginServices.getText(this,"fontrotate")); |
94 |
jLabel5.setPreferredSize(new java.awt.Dimension(100,16)); |
95 |
GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); |
96 |
gridBagConstraints9.fill = java.awt.GridBagConstraints.HORIZONTAL; |
97 |
gridBagConstraints9.gridy = 4;
|
98 |
gridBagConstraints9.weightx = 1.0;
|
99 |
gridBagConstraints9.gridx = 1;
|
100 |
GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); |
101 |
gridBagConstraints8.gridx = 0;
|
102 |
gridBagConstraints8.gridy = 4;
|
103 |
jLabel4 = new JLabel(); |
104 |
jLabel4.setText(PluginServices.getText(this,"fontcolor")); |
105 |
jLabel4.setPreferredSize(new java.awt.Dimension(100,16)); |
106 |
GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); |
107 |
gridBagConstraints7.fill = java.awt.GridBagConstraints.HORIZONTAL; |
108 |
gridBagConstraints7.gridy = 3;
|
109 |
gridBagConstraints7.weightx = 1.0;
|
110 |
gridBagConstraints7.gridx = 1;
|
111 |
GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); |
112 |
gridBagConstraints6.gridx = 0;
|
113 |
gridBagConstraints6.gridy = 3;
|
114 |
jLabel3 = new JLabel(); |
115 |
jLabel3.setText(PluginServices.getText(this,"fontheight")); |
116 |
jLabel3.setPreferredSize(new java.awt.Dimension(100,16)); |
117 |
GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); |
118 |
gridBagConstraints5.fill = java.awt.GridBagConstraints.HORIZONTAL; |
119 |
gridBagConstraints5.gridy = 2;
|
120 |
gridBagConstraints5.weightx = 1.0;
|
121 |
gridBagConstraints5.gridx = 1;
|
122 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
123 |
gridBagConstraints4.gridx = 0;
|
124 |
gridBagConstraints4.gridy = 2;
|
125 |
jLabel2 = new JLabel(); |
126 |
jLabel2.setText(PluginServices.getText(this,"fontstyle")); |
127 |
jLabel2.setPreferredSize(new java.awt.Dimension(100,16)); |
128 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
129 |
gridBagConstraints3.fill = java.awt.GridBagConstraints.HORIZONTAL; |
130 |
gridBagConstraints3.gridy = 1;
|
131 |
gridBagConstraints3.weightx = 1.0;
|
132 |
gridBagConstraints3.gridx = 1;
|
133 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
134 |
gridBagConstraints2.gridx = 0;
|
135 |
gridBagConstraints2.gridy = 1;
|
136 |
jLabel1 = new JLabel(); |
137 |
jLabel1.setText(PluginServices.getText(this,"fonttype")); |
138 |
jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.TRAILING); |
139 |
jLabel1.setPreferredSize(new java.awt.Dimension(100,16)); |
140 |
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEADING); |
141 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
142 |
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; |
143 |
gridBagConstraints1.gridy = 0;
|
144 |
gridBagConstraints1.weightx = 1.0;
|
145 |
gridBagConstraints1.gridx = 1;
|
146 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
147 |
gridBagConstraints.gridx = 0;
|
148 |
gridBagConstraints.gridy = 0;
|
149 |
jLabel = new JLabel(); |
150 |
jLabel.setText(PluginServices.getText(this,"fonttext")); |
151 |
jLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEADING); |
152 |
jLabel.setHorizontalTextPosition(javax.swing.SwingConstants.TRAILING); |
153 |
jLabel.setPreferredSize(new java.awt.Dimension(100,16)); |
154 |
jLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER); |
155 |
jPanel = new JPanel(); |
156 |
jPanel.setLayout(new GridBagLayout()); |
157 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"options"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
158 |
jPanel.add(jLabel, gridBagConstraints); |
159 |
jPanel.add(getTxtText(), gridBagConstraints1); |
160 |
jPanel.add(jLabel1, gridBagConstraints2); |
161 |
jPanel.add(getCmbTypeFont(), gridBagConstraints3); |
162 |
jPanel.add(jLabel2, gridBagConstraints4); |
163 |
jPanel.add(getCmbStyleFont(), gridBagConstraints5); |
164 |
jPanel.add(jLabel3, gridBagConstraints6); |
165 |
jPanel.add(getTxtHeight(), gridBagConstraints7); |
166 |
jPanel.add(jLabel4, gridBagConstraints8); |
167 |
jPanel.add(getColorChooser(), gridBagConstraints9); |
168 |
jPanel.add(jLabel5, gridBagConstraints10); |
169 |
jPanel.add(getTxtRotate(), gridBagConstraints11); |
170 |
} |
171 |
return jPanel;
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* This method initializes jTextField
|
176 |
*
|
177 |
* @return javax.swing.JTextField
|
178 |
*/
|
179 |
private JTextField getTxtText() { |
180 |
if (jTextField == null) { |
181 |
jTextField = new JTextField(); |
182 |
} |
183 |
return jTextField;
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* This method initializes txtTypeFont
|
188 |
*
|
189 |
* @return javax.swing.JTextField
|
190 |
*/
|
191 |
private JComboBox getCmbTypeFont() { |
192 |
if (cmbTypeFont == null) { |
193 |
cmbTypeFont = new JComboBox(); |
194 |
cmbTypeFont.addItem("Arial");
|
195 |
cmbTypeFont.addItem("Dialog");
|
196 |
cmbTypeFont.addItem("DialogInput");
|
197 |
cmbTypeFont.addItem("Serif");
|
198 |
cmbTypeFont.addItem("SansSerif");
|
199 |
cmbTypeFont.addItem("Monospaced");
|
200 |
cmbTypeFont.addItem("Courier");
|
201 |
cmbTypeFont.addItem("TimesRoman");
|
202 |
cmbTypeFont.addItem("Helvetica");
|
203 |
cmbTypeFont.setSelectedItem("Arial");
|
204 |
|
205 |
} |
206 |
return cmbTypeFont;
|
207 |
} |
208 |
|
209 |
/**
|
210 |
* This method initializes txtStyleFont
|
211 |
*
|
212 |
* @return javax.swing.JTextField
|
213 |
*/
|
214 |
private JComboBox getCmbStyleFont() { |
215 |
if (cmbStyleFont == null) { |
216 |
cmbStyleFont = new JComboBox(); |
217 |
cmbStyleFont.addItem("Plain");
|
218 |
cmbStyleFont.addItem("Italic");
|
219 |
cmbStyleFont.addItem("Bold");
|
220 |
cmbStyleFont.setSelectedItem("Plain");
|
221 |
} |
222 |
return cmbStyleFont;
|
223 |
} |
224 |
|
225 |
/**
|
226 |
* This method initializes txtHeight
|
227 |
*
|
228 |
* @return javax.swing.JTextField
|
229 |
*/
|
230 |
private JTextField getTxtHeight() { |
231 |
if (txtHeight == null) { |
232 |
txtHeight = new JTextField(); |
233 |
} |
234 |
return txtHeight;
|
235 |
} |
236 |
|
237 |
/**
|
238 |
* This method initializes txtColor
|
239 |
*
|
240 |
* @return javax.swing.JTextField
|
241 |
*/
|
242 |
private ColorChooserPanel getColorChooser() {
|
243 |
if (colorPanel == null) { |
244 |
colorPanel = new ColorChooserPanel();
|
245 |
} |
246 |
return colorPanel;
|
247 |
} |
248 |
|
249 |
/**
|
250 |
* This method initializes txtRotate
|
251 |
*
|
252 |
* @return javax.swing.JTextField
|
253 |
*/
|
254 |
private JTextField getTxtRotate() { |
255 |
if (txtRotate == null) { |
256 |
txtRotate = new JTextField(); |
257 |
} |
258 |
return txtRotate;
|
259 |
} |
260 |
private AcceptCancelPanel getAcceptCancelPanel() {
|
261 |
if (accept == null) { |
262 |
ActionListener okAction, cancelAction;
|
263 |
okAction = new java.awt.event.ActionListener() {
|
264 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
265 |
isAccepted = true;
|
266 |
PluginServices.getMDIManager().closeWindow( |
267 |
Annotation_ModifyWindow.this); |
268 |
} |
269 |
}; |
270 |
cancelAction = new java.awt.event.ActionListener() {
|
271 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
272 |
isAccepted = false;
|
273 |
PluginServices.getMDIManager().closeWindow( |
274 |
Annotation_ModifyWindow.this); |
275 |
} |
276 |
}; |
277 |
accept = new AcceptCancelPanel(okAction, cancelAction);
|
278 |
accept.setPreferredSize(new java.awt.Dimension(200, 30)); |
279 |
// accept.setBounds(new java.awt.Rectangle(243,387,160,28));
|
280 |
accept.setEnabled(true);
|
281 |
accept.setVisible(true);
|
282 |
} |
283 |
return accept;
|
284 |
} |
285 |
|
286 |
/**
|
287 |
* This method initializes jPanel1
|
288 |
*
|
289 |
* @return javax.swing.JPanel
|
290 |
*/
|
291 |
private JPanel getJPanel1() { |
292 |
if (jPanel1 == null) { |
293 |
jPanel1 = new JPanel(); |
294 |
jPanel1.setLayout(new BorderLayout()); |
295 |
jPanel1.setSize(new java.awt.Dimension(244,142)); |
296 |
jPanel1.add(getJPanel(), java.awt.BorderLayout.NORTH); |
297 |
jPanel1.add(getJPanel2(), java.awt.BorderLayout.SOUTH); |
298 |
} |
299 |
return jPanel1;
|
300 |
} |
301 |
|
302 |
/**
|
303 |
* This method initializes jPanel2
|
304 |
*
|
305 |
* @return javax.swing.JPanel
|
306 |
*/
|
307 |
private JPanel getJPanel2() { |
308 |
if (jPanel2 == null) { |
309 |
jPanel2 = new JPanel(); |
310 |
jPanel2.add(getAcceptCancelPanel(), null);
|
311 |
} |
312 |
return jPanel2;
|
313 |
} |
314 |
|
315 |
public void setValues(Value[] values, Annotation_Mapping am) { |
316 |
this.mapping=am;
|
317 |
getTxtText().setText(values[am.getColumnText()].toString()); |
318 |
getCmbTypeFont().setSelectedItem(values[am.getColumnTypeFont()].toString()); |
319 |
int style=((NumericValue)values[am.getColumnStyleFont()]).intValue();
|
320 |
getCmbStyleFont().setSelectedIndex(style); |
321 |
getTxtHeight().setText(values[am.getColumnHeight()].toString()); |
322 |
int intColor=((NumericValue)values[am.getColumnColor()]).intValue();
|
323 |
Color color=new Color(intColor); |
324 |
getColorChooser().setColor(color); |
325 |
getColorChooser().setAlpha(color.getAlpha()); |
326 |
getTxtRotate().setText(values[am.getColumnRotate()].toString()); |
327 |
|
328 |
} |
329 |
|
330 |
public boolean isAccepted() { |
331 |
return isAccepted;
|
332 |
} |
333 |
|
334 |
public Value[] getValues() { |
335 |
Value[] values=new Value[6]; |
336 |
values[mapping.getColumnText()]=ValueFactory.createValue(getTxtText().getText()); |
337 |
values[mapping.getColumnTypeFont()]=ValueFactory.createValue(getCmbTypeFont().getSelectedItem().toString()); |
338 |
values[mapping.getColumnStyleFont()]=ValueFactory.createValue(getCmbStyleFont().getSelectedIndex()); |
339 |
values[mapping.getColumnHeight()]=ValueFactory.createValue(Double.parseDouble(getTxtHeight().getText()));
|
340 |
values[mapping.getColumnColor()]=ValueFactory.createValue(getColorChooser().getColor().getRGB()); |
341 |
values[mapping.getColumnRotate()]=ValueFactory.createValue(Double.parseDouble(getTxtRotate().getText()));
|
342 |
return values;
|
343 |
} |
344 |
|
345 |
} // @jve:decl-index=0:visual-constraint="10,10"
|