root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / CharacterMarker.java @ 13008
History | View | Annotate | Download (16.4 KB)
1 | 9745 | jaume | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2005 IVER T.I. 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 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | |||
42 | /* CVS MESSAGES:
|
||
43 | *
|
||
44 | * $Id$
|
||
45 | * $Log$
|
||
46 | 12980 | jaume | * Revision 1.18 2007-08-08 11:45:38 jaume
|
47 | * some bugs fixed
|
||
48 | *
|
||
49 | * Revision 1.17 2007/08/07 11:21:05 jvidal
|
||
50 | 12937 | jvidal | * javadoc
|
51 | *
|
||
52 | * Revision 1.16 2007/08/03 11:29:13 jaume
|
||
53 | 12911 | jaume | * refactored AbstractTypeSymbolEditorPanel class name to AbastractTypeSymbolEditor
|
54 | *
|
||
55 | * Revision 1.15 2007/07/30 12:56:04 jaume
|
||
56 | 12826 | jaume | * organize imports, java 5 code downgraded to 1.4 and added PictureFillSymbol
|
57 | *
|
||
58 | * Revision 1.14 2007/07/12 10:43:55 jaume
|
||
59 | 12561 | jaume | * *** empty log message ***
|
60 | *
|
||
61 | * Revision 1.13 2007/06/29 13:07:33 jaume
|
||
62 | 12427 | jaume | * +PictureLineSymbol
|
63 | *
|
||
64 | * Revision 1.12 2007/05/31 09:36:22 jaume
|
||
65 | 11548 | jaume | * *** empty log message ***
|
66 | *
|
||
67 | 11919 | jaume | * Revision 1.11 2007/05/29 15:47:06 jaume
|
68 | * *** empty log message ***
|
||
69 | *
|
||
70 | 11877 | jaume | * Revision 1.10 2007/05/21 10:38:27 jaume
|
71 | * *** empty log message ***
|
||
72 | *
|
||
73 | 11734 | jaume | * Revision 1.9 2007/05/09 16:08:14 jaume
|
74 | * *** empty log message ***
|
||
75 | *
|
||
76 | 11548 | jaume | * Revision 1.8 2007/04/26 11:40:09 jaume
|
77 | 11734 | jaume | * added new components (JIncrementalNumberField)
|
78 | 11371 | jaume | *
|
79 | * Revision 1.7 2007/04/20 07:54:38 jaume
|
||
80 | 11271 | jaume | * *** empty log message ***
|
81 | *
|
||
82 | 11297 | jaume | * Revision 1.6 2007/04/19 14:22:20 jaume
|
83 | * *** empty log message ***
|
||
84 | *
|
||
85 | 11271 | jaume | * Revision 1.5 2007/04/05 16:08:34 jaume
|
86 | 11073 | jaume | * Styled labeling stuff
|
87 | *
|
||
88 | * Revision 1.4 2007/04/04 16:01:13 jaume
|
||
89 | 10993 | jaume | * *** empty log message ***
|
90 | *
|
||
91 | 11055 | jaume | * Revision 1.3 2007/03/30 12:54:11 jaume
|
92 | * *** empty log message ***
|
||
93 | *
|
||
94 | 10993 | jaume | * Revision 1.2 2007/03/09 11:25:00 jaume
|
95 | 10679 | jaume | * Advanced symbology (start committing)
|
96 | *
|
||
97 | * Revision 1.1.2.7 2007/02/21 07:35:14 jaume
|
||
98 | 9745 | jaume | * *** empty log message ***
|
99 | *
|
||
100 | 10679 | jaume | * Revision 1.1.2.6 2007/02/08 15:43:05 jaume
|
101 | * some bug fixes in the editor and removed unnecessary imports
|
||
102 | *
|
||
103 | * Revision 1.1.2.5 2007/02/05 14:58:28 jaume
|
||
104 | * *** empty log message ***
|
||
105 | *
|
||
106 | * Revision 1.1.2.3 2007/02/04 16:57:22 jaume
|
||
107 | * working the map of characters
|
||
108 | *
|
||
109 | * Revision 1.1.2.2 2007/02/02 16:21:32 jaume
|
||
110 | * *** empty log message ***
|
||
111 | *
|
||
112 | * Revision 1.1.2.1 2007/01/26 13:49:03 jaume
|
||
113 | * *** empty log message ***
|
||
114 | *
|
||
115 | * Revision 1.1 2007/01/16 11:52:11 jaume
|
||
116 | * *** empty log message ***
|
||
117 | *
|
||
118 | 9745 | jaume | * Revision 1.3 2006/11/06 17:08:45 jaume
|
119 | * *** empty log message ***
|
||
120 | *
|
||
121 | * Revision 1.2 2006/11/06 16:06:52 jaume
|
||
122 | * *** empty log message ***
|
||
123 | *
|
||
124 | * Revision 1.1 2006/10/31 16:16:34 jaume
|
||
125 | * *** empty log message ***
|
||
126 | *
|
||
127 | *
|
||
128 | */
|
||
129 | package com.iver.cit.gvsig.gui.styling; |
||
130 | |||
131 | 10679 | jaume | import java.awt.BorderLayout; |
132 | import java.awt.Color; |
||
133 | import java.awt.Component; |
||
134 | import java.awt.Dimension; |
||
135 | import java.awt.Font; |
||
136 | import java.awt.event.ActionEvent; |
||
137 | import java.awt.event.ActionListener; |
||
138 | 11271 | jaume | import java.awt.geom.Point2D; |
139 | 9745 | jaume | import java.util.ArrayList; |
140 | |||
141 | 11271 | jaume | import javax.swing.BorderFactory; |
142 | 10679 | jaume | import javax.swing.BoxLayout; |
143 | 12427 | jaume | import javax.swing.JCheckBox; |
144 | 10679 | jaume | import javax.swing.JComponent; |
145 | import javax.swing.JLabel; |
||
146 | import javax.swing.JList; |
||
147 | 9745 | jaume | import javax.swing.JPanel; |
148 | 10679 | jaume | import javax.swing.JScrollPane; |
149 | import javax.swing.ListCellRenderer; |
||
150 | import javax.swing.ListModel; |
||
151 | import javax.swing.event.ListDataListener; |
||
152 | import javax.swing.event.ListSelectionEvent; |
||
153 | import javax.swing.event.ListSelectionListener; |
||
154 | 9745 | jaume | |
155 | 10679 | jaume | import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
156 | 11919 | jaume | import org.gvsig.gui.beans.swing.JComboBoxFontSizes; |
157 | import org.gvsig.gui.beans.swing.JComboBoxFonts; |
||
158 | 11734 | jaume | import org.gvsig.gui.beans.swing.JIncrementalNumberField; |
159 | 10679 | jaume | |
160 | 9745 | jaume | import com.iver.andami.PluginServices; |
161 | 10679 | jaume | import com.iver.andami.messages.NotificationManager; |
162 | import com.iver.cit.gvsig.fmap.core.symbols.CharacterMarkerSymbol; |
||
163 | import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
||
164 | 12826 | jaume | import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
165 | 11271 | jaume | import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
166 | 9745 | jaume | |
167 | 11271 | jaume | |
168 | 11371 | jaume | |
169 | 11055 | jaume | /**
|
170 | 12937 | jvidal | * CharacterMarker allows the user to store and modify the properties that
|
171 | * define a <b>character marker</b>.<p>
|
||
172 | * <p>
|
||
173 | * This functionality is carried out thanks to two tabs (character marker and mask)which
|
||
174 | * are included in the panel to edit the properities of a symbol (SymbolEditor)how
|
||
175 | * is explained in AbstractTypeSymbolEditor.<p>
|
||
176 | * <p>
|
||
177 | * The first tab (Character marker)allows the user to change the font (<b>cmbFonts</b>)of
|
||
178 | * the symbol for the character marker, the size of that (<b>cmbFontSize</b>),the angle
|
||
179 | *(<b>numberAngle</b>)if the user wants to show the character with some rotation,the color
|
||
180 | * (<b>jcc</b>) and the offset (<b>txtYOffset,txtXOffset</b>).<p>
|
||
181 | * <p>
|
||
182 | * The second tab (<b>Mask</b>) modifies attributes of a mask for points such
|
||
183 | * as style,size and symbol (to represent a point in the map).<p>
|
||
184 | *
|
||
185 | *@see Mask
|
||
186 | *@see AbstractTypeSymbolEditor
|
||
187 | *@author jaume dominguez faus - jaume.dominguez@iver.es
|
||
188 | */
|
||
189 | 12911 | jaume | public class CharacterMarker extends AbstractTypeSymbolEditor implements ActionListener { |
190 | 9745 | jaume | private ArrayList tabs = new ArrayList(); |
191 | 10679 | jaume | private JList jListSymbols; |
192 | private JScrollPane jScrollPane; |
||
193 | 11919 | jaume | private JComboBoxFonts cmbFonts;
|
194 | 11548 | jaume | private Mask mask;
|
195 | 11919 | jaume | private JComboBoxFontSizes cmbFontSize;
|
196 | 11734 | jaume | private JIncrementalNumberField numberAngle;
|
197 | 11271 | jaume | private ColorChooserPanel jcc;
|
198 | 11734 | jaume | private JIncrementalNumberField txtYOffset;
|
199 | private JIncrementalNumberField txtXOffset;
|
||
200 | 11271 | jaume | private Font font; |
201 | private int unicode; |
||
202 | 12427 | jaume | private JCheckBox chkAdjustGlyph; |
203 | 9745 | jaume | |
204 | 12937 | jvidal | /**
|
205 | * contructor method
|
||
206 | * @param owner
|
||
207 | */
|
||
208 | 9745 | jaume | public CharacterMarker(SymbolEditor owner) {
|
209 | super(owner);
|
||
210 | initialize(); |
||
211 | } |
||
212 | 12937 | jvidal | /**
|
213 | * Initializes the parameters that define a charactermarker.To do it, two tabs
|
||
214 | * are created inside the SymbolEditor panel with default values for the
|
||
215 | * different attributes of the character marker.This two tabs will be character
|
||
216 | * marker tab (options of font,size,angle,color and the offset of the character
|
||
217 | * marker)and a Mask added as a new tab.
|
||
218 | *
|
||
219 | */
|
||
220 | 9745 | jaume | private void initialize() { |
221 | JPanel myTab;
|
||
222 | { |
||
223 | 11271 | jaume | // Character marker tab
|
224 | myTab = new JPanel(new BorderLayout(10, 10)); |
||
225 | 9745 | jaume | myTab.setName(PluginServices.getText(this, "character_marker")); |
226 | 10679 | jaume | myTab.setLayout(new BorderLayout(15,15)); |
227 | |||
228 | 11271 | jaume | JPanel aux = new JPanel(new BorderLayout(15, 15)); |
229 | aux.add(new JLabel(PluginServices.getText(this, "font")+":"), BorderLayout.NORTH); |
||
230 | aux.add(getCmbFonts(), BorderLayout.NORTH);
|
||
231 | |||
232 | getJListSymbols().setModel( |
||
233 | new CharacterListModel(
|
||
234 | new Font((String) getCmbFonts().getSelectedItem(), Font.PLAIN, 14))); |
||
235 | aux.add(getJScrollPane(), BorderLayout.CENTER);
|
||
236 | myTab.add(aux, BorderLayout.CENTER);
|
||
237 | |||
238 | GridBagLayoutPanel aux1 = new GridBagLayoutPanel();
|
||
239 | aux1.addComponent(PluginServices.getText(this, "size")+":", getCmbFontSize()); |
||
240 | aux1.addComponent(PluginServices.getText(this, "angle")+":", getNumberAngle()); |
||
241 | |||
242 | aux1.addComponent(PluginServices.getText(this, "color")+":", getColorChooser()); |
||
243 | |||
244 | GridBagLayoutPanel aux2 = new GridBagLayoutPanel();
|
||
245 | aux2.addComponent("X:", getTxtXOffset());
|
||
246 | aux2.addComponent("Y:", getTxtYOffset());
|
||
247 | aux2.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(this, "offset"))); |
||
248 | aux1.addComponent(aux2); |
||
249 | |||
250 | myTab.add(aux1, BorderLayout.EAST);
|
||
251 | 12427 | jaume | myTab.add(getChkAdjustGlyph(), BorderLayout.SOUTH);
|
252 | 11877 | jaume | |
253 | 11271 | jaume | tabs.add(myTab); |
254 | } |
||
255 | |||
256 | { |
||
257 | // Mask tab
|
||
258 | 11548 | jaume | mask = new Mask(this); |
259 | 11271 | jaume | |
260 | 11548 | jaume | tabs.add(mask); |
261 | 9745 | jaume | } |
262 | 12980 | jaume | |
263 | jListSymbols.addListSelectionListener(new ListSelectionListener() { |
||
264 | public void valueChanged(ListSelectionEvent e) { |
||
265 | fireSymbolChangedEvent(); |
||
266 | } |
||
267 | }); |
||
268 | 9745 | jaume | } |
269 | |||
270 | 12937 | jvidal | /**
|
271 | * JCheckBox that allows the user to apply visual correction to glyph for
|
||
272 | * precise size and position.
|
||
273 | * @return JCheckBox
|
||
274 | */
|
||
275 | 12427 | jaume | private JCheckBox getChkAdjustGlyph() { |
276 | if (chkAdjustGlyph == null) { |
||
277 | chkAdjustGlyph = new JCheckBox(PluginServices.getText(this, "apply_visual_correction_to_glyph_for_precise_size_and_position")); |
||
278 | chkAdjustGlyph.addActionListener(this);
|
||
279 | } |
||
280 | |||
281 | return chkAdjustGlyph;
|
||
282 | } |
||
283 | |||
284 | 12937 | jvidal | /**
|
285 | * JIncrementalNumberField that controls the YOffset for the character that the
|
||
286 | * user wants to use as a marker.
|
||
287 | * @return JIncrementalNumberField
|
||
288 | */
|
||
289 | 11734 | jaume | private JIncrementalNumberField getTxtYOffset() {
|
290 | 11271 | jaume | if (txtYOffset == null) { |
291 | 11734 | jaume | txtYOffset = new JIncrementalNumberField(String.valueOf(0), 7); |
292 | 11877 | jaume | txtYOffset.addActionListener(this);
|
293 | 11271 | jaume | } |
294 | |||
295 | return txtYOffset;
|
||
296 | } |
||
297 | 12937 | jvidal | /**
|
298 | * JIncrementalNumberField that controls the XOffset for the character that the
|
||
299 | * user wants to use as a marker.
|
||
300 | * @return JIncrementalNumberField
|
||
301 | */
|
||
302 | 11734 | jaume | private JIncrementalNumberField getTxtXOffset() {
|
303 | 11271 | jaume | if (txtXOffset == null) { |
304 | 11734 | jaume | txtXOffset = new JIncrementalNumberField(String.valueOf(0), 7); |
305 | 11877 | jaume | txtXOffset.addActionListener(this);
|
306 | 11271 | jaume | } |
307 | |||
308 | return txtXOffset;
|
||
309 | } |
||
310 | 12937 | jvidal | /**
|
311 | * ColorChooserPanel used to select the color for the character that the
|
||
312 | * user wants to use as a marker.
|
||
313 | * @return ColorChooserPanel
|
||
314 | */
|
||
315 | 11271 | jaume | private ColorChooserPanel getColorChooser() {
|
316 | if (jcc == null) { |
||
317 | jcc = new ColorChooserPanel();
|
||
318 | jcc.setAlpha(255);
|
||
319 | 11877 | jaume | jcc.addActionListener(this);
|
320 | 11271 | jaume | } |
321 | |||
322 | return jcc;
|
||
323 | } |
||
324 | 12937 | jvidal | /**
|
325 | * JComboBoxFontSizes that allows the user to change the size of the character
|
||
326 | * selected as a marker
|
||
327 | * @return JComboBoxFontSizes
|
||
328 | */
|
||
329 | 11919 | jaume | private JComboBoxFontSizes getCmbFontSize() {
|
330 | 11271 | jaume | if (cmbFontSize == null) { |
331 | 11919 | jaume | cmbFontSize = new JComboBoxFontSizes();
|
332 | 11877 | jaume | cmbFontSize.addActionListener(this);
|
333 | 11271 | jaume | } |
334 | |||
335 | return cmbFontSize;
|
||
336 | } |
||
337 | 12937 | jvidal | /**
|
338 | * JIncrementalNumberField that controls the angle (if the user wants to show the
|
||
339 | * character with some rotation) for the character that the user wants to use as
|
||
340 | * a marker.
|
||
341 | * @return JIncrementalNumberField
|
||
342 | */
|
||
343 | 11271 | jaume | |
344 | 11734 | jaume | private JIncrementalNumberField getNumberAngle() {
|
345 | 11271 | jaume | if (numberAngle == null) { |
346 | 11734 | jaume | numberAngle = new JIncrementalNumberField(String.valueOf(0), 5); |
347 | 11877 | jaume | numberAngle.addActionListener(this);
|
348 | 11371 | jaume | |
349 | 11271 | jaume | } |
350 | |||
351 | return numberAngle;
|
||
352 | } |
||
353 | |||
354 | 12937 | jvidal | /**
|
355 | * JComboBoxFonts its a combobox of fonts where the user can select the font
|
||
356 | * for the character marker.Depends on this font, the character will change its
|
||
357 | * appearance.
|
||
358 | * @returnJComboBoxFonts
|
||
359 | */
|
||
360 | 11919 | jaume | private JComboBoxFonts getCmbFonts() {
|
361 | 10679 | jaume | if (cmbFonts == null) { |
362 | 11919 | jaume | cmbFonts = new JComboBoxFonts();
|
363 | 10679 | jaume | cmbFonts.addActionListener(this);
|
364 | } |
||
365 | return cmbFonts;
|
||
366 | 9745 | jaume | } |
367 | 12937 | jvidal | /**
|
368 | * JScrollPane to select the exact character marker.The content of this pane
|
||
369 | * will change depending on the font that the user had selected.
|
||
370 | * @return JScrollPane
|
||
371 | */
|
||
372 | 9745 | jaume | |
373 | 10679 | jaume | private JScrollPane getJScrollPane() { |
374 | if (jScrollPane == null) { |
||
375 | jScrollPane = new JScrollPane(); |
||
376 | jScrollPane.setViewportView(getJListSymbols()); |
||
377 | jScrollPane.setPreferredSize(new Dimension(300, 180)); |
||
378 | } |
||
379 | return jScrollPane;
|
||
380 | } |
||
381 | 12937 | jvidal | /**
|
382 | * Used with the JScrollPane to create the pane that allows the user to select the
|
||
383 | * character marker.
|
||
384 | * @see getJScrollPane()
|
||
385 | * @return JList
|
||
386 | */
|
||
387 | 10679 | jaume | private JList getJListSymbols() { |
388 | if (jListSymbols == null) { |
||
389 | jListSymbols = new JList(); |
||
390 | jListSymbols.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
||
391 | jListSymbols.setLayoutOrientation(JList.HORIZONTAL_WRAP);
|
||
392 | jListSymbols.setVisibleRowCount(-1);
|
||
393 | jListSymbols.addListSelectionListener(new ListSelectionListener() { |
||
394 | 11271 | jaume | |
395 | 10679 | jaume | public void valueChanged(ListSelectionEvent e) { |
396 | CharacterItem theChar = (CharacterItem) jListSymbols.getSelectedValue(); |
||
397 | 11271 | jaume | if (theChar == null) return; |
398 | font = theChar.font; |
||
399 | unicode = theChar.glyph; |
||
400 | 11877 | jaume | fireSymbolChangedEvent(); |
401 | 10679 | jaume | } |
402 | }); |
||
403 | ListCellRenderer renderer = new ListCellRenderer() { |
||
404 | private Color mySelectedBGColor = new Color(255,145,100,255); |
||
405 | public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||
406 | CharacterItem theChar = (CharacterItem) value; |
||
407 | CharacterMarkerSymbol sym = new CharacterMarkerSymbol(theChar.font, theChar.glyph, Color.BLACK); |
||
408 | JPanel pnl = new JPanel(); |
||
409 | BoxLayout layout = new BoxLayout(pnl, BoxLayout.Y_AXIS); |
||
410 | pnl.setLayout(layout); |
||
411 | Color bgColor = (isSelected) ? mySelectedBGColor
|
||
412 | : getJListSymbols().getBackground(); |
||
413 | |||
414 | pnl.setBackground(bgColor); |
||
415 | SymbolPreviewer sp = new SymbolPreviewer();
|
||
416 | sp.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||
417 | 10993 | jaume | int prevSize = 30; |
418 | sp.setPreferredSize(new Dimension(prevSize, prevSize)); |
||
419 | 10679 | jaume | sp.setSymbol(sym); |
420 | sp.setBackground(bgColor); |
||
421 | 10993 | jaume | sym.setSize(prevSize*.8);
|
422 | 12427 | jaume | // sym.setVisuallyCorrected(getChkAdjustGlyph().isSelected());
|
423 | 10679 | jaume | pnl.add(sp); |
424 | JLabel lbl = new JLabel(sym.getDescription()); |
||
425 | lbl.setBackground(bgColor); |
||
426 | lbl.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||
427 | pnl.add(lbl); |
||
428 | |||
429 | return pnl;
|
||
430 | } |
||
431 | }; |
||
432 | jListSymbols.setCellRenderer(renderer); |
||
433 | } |
||
434 | return jListSymbols;
|
||
435 | } |
||
436 | |||
437 | |||
438 | 9745 | jaume | public String getName() { |
439 | return PluginServices.getText(this, "character_marker_symbol"); |
||
440 | } |
||
441 | |||
442 | public JPanel[] getTabs() { |
||
443 | return (JPanel[]) tabs .toArray(new JPanel[0]); |
||
444 | } |
||
445 | |||
446 | 10679 | jaume | public void refreshControls(ISymbol layer) { |
447 | CharacterMarkerSymbol sym; |
||
448 | try {
|
||
449 | 11877 | jaume | |
450 | 10679 | jaume | sym = (CharacterMarkerSymbol) layer; |
451 | 11877 | jaume | font = sym.getFont(); |
452 | unicode = sym.getUnicode(); |
||
453 | getTxtXOffset().setDouble( sym.getOffset().getX() ); |
||
454 | getTxtYOffset().setDouble( -sym.getOffset().getY() ); |
||
455 | |||
456 | 11271 | jaume | getCmbFonts().setSelectedItem(sym.getFont().getName()); |
457 | getCmbFontSize().setSelectedItem(new Integer(sym.getFont().getSize())); |
||
458 | getJListSymbols().setSelectedIndex(sym.getUnicode()); |
||
459 | 12826 | jaume | getNumberAngle().setDouble( sym.getRotation()/FConstant.DEGREE_TO_RADIANS ); |
460 | 11271 | jaume | getColorChooser().setColor(sym.getColor()); |
461 | 12427 | jaume | getChkAdjustGlyph().setSelected(sym.isVisuallyCorrected()); |
462 | 11297 | jaume | |
463 | 11271 | jaume | // TODO mask
|
464 | 10679 | jaume | } catch (IndexOutOfBoundsException ioEx) { |
465 | NotificationManager.addWarning("Symbol layer index out of bounds", ioEx);
|
||
466 | } catch (ClassCastException ccEx) { |
||
467 | NotificationManager.addWarning("Illegal casting from " +
|
||
468 | layer.getClassName() + " to " + getSymbolClass().
|
||
469 | getName() + ".", ccEx);
|
||
470 | 9745 | jaume | |
471 | 10679 | jaume | } |
472 | |||
473 | 9745 | jaume | } |
474 | |||
475 | public Class getSymbolClass() { |
||
476 | 10679 | jaume | return CharacterMarkerSymbol.class;
|
477 | 9745 | jaume | } |
478 | |||
479 | 10679 | jaume | public ISymbol getLayer() {
|
480 | 11271 | jaume | CharacterMarkerSymbol layer = new CharacterMarkerSymbol();
|
481 | 12980 | jaume | if (font == null) { |
482 | font = new Font((String) getCmbFonts().getSelectedItem(), |
||
483 | Font.PLAIN,
|
||
484 | (int) getCmbFontSize().getSelectedValue());
|
||
485 | } |
||
486 | 11271 | jaume | layer.setFont(font); |
487 | layer.setUnicode(unicode); |
||
488 | layer.setColor(getColorChooser().getColor()); |
||
489 | layer.setSize(getCmbFontSize().getSelectedValue()); |
||
490 | layer.setOffset(new Point2D.Double( |
||
491 | 11371 | jaume | getTxtXOffset().getDouble(), |
492 | -getTxtYOffset().getDouble())); |
||
493 | 12826 | jaume | layer.setRotation(getNumberAngle().getDouble()*FConstant.DEGREE_TO_RADIANS); |
494 | 11297 | jaume | |
495 | 12561 | jaume | layer.setUnit(owner.getUnit()); |
496 | layer.setReferenceSystem(owner.getUnitsReferenceSystem()); |
||
497 | 11548 | jaume | layer.setMask(mask.getMask()); |
498 | 12427 | jaume | layer.setVisuallyCorrected(getChkAdjustGlyph().isSelected()); |
499 | 12980 | jaume | System.out.println("getalyer"); |
500 | 10679 | jaume | return layer;
|
501 | } |
||
502 | |||
503 | 12937 | jvidal | /**
|
504 | * Creates a list with the specified items.
|
||
505 | *
|
||
506 | */
|
||
507 | 10679 | jaume | private class CharacterListModel implements ListModel { |
508 | |||
509 | private Font font; |
||
510 | private ArrayList listeners; |
||
511 | |||
512 | 12937 | jvidal | /**
|
513 | * constructor method
|
||
514 | * @param font
|
||
515 | */
|
||
516 | 10679 | jaume | public CharacterListModel(Font font) { |
517 | this.font = font;
|
||
518 | } |
||
519 | |||
520 | public int getSize() { |
||
521 | return font.getNumGlyphs();
|
||
522 | } |
||
523 | |||
524 | public Object getElementAt(int index) { |
||
525 | return new CharacterItem(font, index); |
||
526 | } |
||
527 | |||
528 | public void addListDataListener(ListDataListener l) { |
||
529 | if (listeners == null) |
||
530 | listeners = new ArrayList(); |
||
531 | listeners.add(l); |
||
532 | } |
||
533 | |||
534 | public void removeListDataListener(ListDataListener l) { |
||
535 | if (listeners!=null) |
||
536 | listeners.remove(l); |
||
537 | } |
||
538 | } |
||
539 | |||
540 | private class CharacterItem { |
||
541 | int glyph;
|
||
542 | Font font;
|
||
543 | public CharacterItem(Font font, int glyph) { |
||
544 | this.font = font;
|
||
545 | this.glyph = glyph;
|
||
546 | } |
||
547 | } |
||
548 | |||
549 | public void actionPerformed(ActionEvent e) { |
||
550 | JComponent c = (JComponent) e.getSource(); |
||
551 | if (c.equals(getCmbFonts())) {
|
||
552 | String fontName = (String) getCmbFonts().getSelectedItem(); |
||
553 | getJListSymbols().setModel( |
||
554 | new CharacterListModel(
|
||
555 | new Font(fontName, Font.PLAIN, 10))); |
||
556 | 12980 | jaume | return;
|
557 | 10679 | jaume | } |
558 | 11877 | jaume | |
559 | 12980 | jaume | System.out.println("actionPerformed"); |
560 | 11877 | jaume | fireSymbolChangedEvent(); |
561 | 10679 | jaume | } |
562 | 12980 | jaume | |
563 | public EditorTool[] getEditorTools() { |
||
564 | 11073 | jaume | return null; |
565 | } |
||
566 | 9745 | jaume | } |