Statistics
| Revision:

root / trunk / extensions / extSymbology / src / org / gvsig / symbology / gui / layerproperties / LabelClassProperties.java @ 24385

History | View | Annotate | Download (20.4 KB)

1
/* 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
package org.gvsig.symbology.gui.layerproperties;
42

    
43
import java.awt.BorderLayout;
44
import java.awt.Component;
45
import java.awt.Dimension;
46
import java.awt.FlowLayout;
47
import java.awt.GridLayout;
48
import java.awt.event.ActionEvent;
49
import java.awt.event.ActionListener;
50
import java.awt.event.FocusEvent;
51
import java.awt.event.FocusListener;
52
import java.awt.event.KeyEvent;
53
import java.awt.event.KeyListener;
54
import java.io.ByteArrayInputStream;
55
import java.sql.Types;
56

    
57
import javax.swing.BorderFactory;
58
import javax.swing.ButtonGroup;
59
import javax.swing.JCheckBox;
60
import javax.swing.JComponent;
61
import javax.swing.JFrame;
62
import javax.swing.JLabel;
63
import javax.swing.JPanel;
64
import javax.swing.JRadioButton;
65
import javax.swing.JScrollPane;
66
import javax.swing.JTable;
67
import javax.swing.JTextField;
68
import javax.swing.table.DefaultTableModel;
69
import javax.swing.table.TableColumnModel;
70

    
71
import org.gvsig.gui.beans.AcceptCancelPanel;
72
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
73
import org.gvsig.gui.beans.swing.JBlank;
74
import org.gvsig.gui.beans.swing.JButton;
75
import org.gvsig.symbology.fmap.labeling.OnSelectionLabeled;
76
import org.gvsig.symbology.fmap.labeling.parse.LabelExpressionParser;
77
import org.gvsig.symbology.fmap.styles.SimpleLabelStyle;
78

    
79
import com.iver.andami.PluginServices;
80
import com.iver.andami.ui.mdiManager.IWindow;
81
import com.iver.andami.ui.mdiManager.WindowInfo;
82
import com.iver.cit.gvsig.fmap.core.FShape;
83
import com.iver.cit.gvsig.fmap.core.styles.ILabelStyle;
84
import com.iver.cit.gvsig.fmap.core.styles.IStyle;
85
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.ILabelingStrategy;
86
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelClass;
87
import com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelingFactory;
88
import com.iver.cit.gvsig.gui.styling.AbstractStyleSelectorFilter;
89
import com.iver.cit.gvsig.gui.styling.StylePreviewer;
90
import com.iver.cit.gvsig.gui.styling.StyleSelector;
91
import com.iver.utiles.XMLEntity;
92
import com.iver.utiles.xml.XMLEncodingUtils;
93
import com.iver.utiles.xmlEntity.generate.XmlTag;
94

    
95
/**
96
 *
97
 * LabelClassProperties.java
98
 *
99
 *
100
 * @author jaume dominguez faus - jaume.dominguez@iver.es May 27, 2008
101
 *
102
 */
103
public class LabelClassProperties extends JPanel implements IWindow,
104
ActionListener {
105
        private static final String TEST_SQL = "TEST_SQL";
106
        private static final String DELETE_FIELD = "DELETE_FIELD";
107
        private static final long serialVersionUID = 6528513396536811057L;
108
        private static final String ADD_FIELD = "ADD_FIELD";
109
        private static final String SELECT_STYLE = "SELECT_STYLE";
110
        private static final String CLEAR_STYLE = "CLEAR_STYLE";
111
        private JTextField txtName;
112
        private LabelClass lc, clonedClass;
113
        private JTable tblExpressions;
114
        private JButton btnRemoveField;
115
        private JButton btnAddField;
116
        private JComponent styPreviewer;
117
        private JButton btnSelStyle;
118
        private JRadioButton rdBtnFilteredFeatures;
119
        private JRadioButton rdBtnAllFeatures;
120
        private JTextField txtSQL;
121
        private JCheckBox chkLabelFeatures;
122
        private LabelTextStylePanel textStyle;
123
        private JPanel sqlPnl;
124
        private LabelClassPreview labelPreview;
125
        private String[] fieldNames;
126
        private int[] fieldTypes;
127
        private JButton btnDontUseStyle;
128

    
129

    
130

    
131
        /**
132
         * <p>
133
         * Creates a new instance of the dialog that configures all the properties
134
         * of a LabelClass.
135
         * </p>
136
         * @param strategy
137
         * @param asWindow
138
         */
139
        public LabelClassProperties(String[] fieldNames, int[] fieldTypes) {
140
                if (fieldNames==null)  {
141
                        throw new IllegalArgumentException("fieldNames "+
142
                                        PluginServices.getText(this, "cannot_be_null"));
143
                }
144

    
145
                if (fieldTypes==null) {
146
                        throw new IllegalArgumentException("fieldTypes "+
147
                                        PluginServices.getText(this, "cannot_be_null"));
148

    
149
                }
150

    
151
                if (fieldNames.length != fieldTypes.length) {
152
                        throw new IllegalArgumentException(
153
                                        PluginServices.getText(this, "names_and_types_count_are_disctint"));
154
                }
155
                this.fieldNames = fieldNames;
156
                this.fieldTypes = fieldTypes;
157
                initialize();
158
        }
159

    
160
        private void initialize() {
161
                setPreferredSize(new Dimension(810, 500));
162
                setLayout(new BorderLayout(1, 1));
163

    
164
                txtName = new JTextField(40);
165
                JPanel northPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 2));
166
                northPanel.add(new JLabel(PluginServices.getText(this, "name") + ":"));
167
                northPanel.add(txtName);
168
                add(northPanel, BorderLayout.NORTH);
169

    
170
                JPanel centerPanel = new JPanel(new BorderLayout(10, 10));
171
                textStyle = new LabelTextStylePanel();
172
                textStyle.addActionListener(this);
173
                centerPanel.add(textStyle, BorderLayout.NORTH);
174

    
175
                JPanel labelExpressionsPanel = new JPanel(new BorderLayout(1, 1));
176

    
177
                labelExpressionsPanel.add(new JBlank(10, 30), BorderLayout.WEST);
178
                labelExpressionsPanel.add(new JScrollPane(getTableFields()),
179
                                BorderLayout.CENTER);
180

    
181
                JPanel a = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
182
                a.add(new JLabel("<html><b>"+PluginServices
183
                                .getText(this, "text_fields")+"</b></html>"));
184
                centerPanel.add(labelExpressionsPanel, BorderLayout.CENTER);
185
                GridBagLayoutPanel aux = new GridBagLayoutPanel();// (new
186
                // FlowLayout(FlowLayout.CENTER));
187
                aux.setPreferredSize(new Dimension(120, 100));
188
                aux.addComponent(getBtnAddField());
189
                aux.addComponent(getBtnRemoveField());
190
                centerPanel.add(aux, BorderLayout.EAST);
191

    
192

    
193
                aux = new GridBagLayoutPanel();
194
//                aux.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(
195
//                this, "features")));
196
                rdBtnAllFeatures = new JRadioButton(PluginServices.getText(this,
197
                "all_features"));
198
                rdBtnFilteredFeatures = new JRadioButton(PluginServices.getText(this,
199
                "filtered_features"));
200

    
201
                rdBtnAllFeatures.addActionListener(this);
202
                rdBtnFilteredFeatures.addActionListener(this);
203

    
204
                ButtonGroup g = new ButtonGroup();
205
                g.add(rdBtnAllFeatures);
206
                g.add(rdBtnFilteredFeatures);
207
                aux.addComponent(chkLabelFeatures = new JCheckBox(PluginServices
208
                                .getText(this, "label_features_in_this_class")));
209
                aux.addComponent("", rdBtnAllFeatures);
210
                aux.addComponent("", rdBtnFilteredFeatures);
211
                sqlPnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
212
                sqlPnl.add(new JLabel("   SQL: select * from "));
213
                sqlPnl.add(new JLabel("%" + PluginServices.getText(this, "layer_name")
214
                                + "%"));
215
                sqlPnl.add(new JLabel(" where  "));
216
                sqlPnl.add(txtSQL = new JTextField(40));
217
                sqlPnl.add(new JLabel(";"));
218
                aux.addComponent("", sqlPnl);
219

    
220

    
221
                JPanel auxPanel = new JPanel(new BorderLayout(1,1));
222

    
223
                JPanel aux2 = new JPanel();
224
                auxPanel.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(
225
                                this, "background_style")));
226

    
227
                aux2.add(getStylePreviewer());
228

    
229

    
230

    
231
                GridBagLayoutPanel aux3 = new GridBagLayoutPanel();
232
                aux3.setPreferredSize(new Dimension(120, 100));
233
                aux3.addComponent(getBtnSelectStyle());
234
                aux3.addComponent(getBtnDontUseStyle());
235

    
236
                auxPanel.add(aux2,BorderLayout.CENTER);
237
                auxPanel.add(aux3,BorderLayout.EAST);
238

    
239
                JPanel aux4 = new JPanel(new GridLayout(1,2));
240
                aux4.add(auxPanel);
241
                aux2 = new JPanel(new BorderLayout());
242
                aux2.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(
243
                                this, "preview")));
244
                aux2.add(labelPreview = new LabelClassPreview(), BorderLayout.CENTER);
245
                aux4.add(aux2);
246

    
247
                GridBagLayoutPanel aux5 = new GridBagLayoutPanel();
248
                aux5.addComponent("", aux);
249
                aux5.addComponent(new JBlank(3, 5));
250
                aux5.addComponent("", aux4);
251
                centerPanel.add(aux5, BorderLayout.SOUTH);
252
                add(centerPanel, BorderLayout.CENTER);
253

    
254
                add(new AcceptCancelPanel(this, this), BorderLayout.SOUTH);
255

    
256
                chkLabelFeatures.addActionListener(this);
257
                txtName.addActionListener(this);
258

    
259
        }
260

    
261
        private JComponent getStylePreviewer() {
262

    
263
                if (styPreviewer == null) {
264
                        styPreviewer = new StylePreviewer();
265
                        styPreviewer.setPreferredSize(new java.awt.Dimension(90,90));
266
                        styPreviewer.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
267
                        ((StylePreviewer) styPreviewer).setShowOutline(true);
268
                }
269
                return styPreviewer;
270

    
271
        }
272

    
273
        private JButton getBtnSelectStyle() {
274
                if (btnSelStyle == null) {
275
                        btnSelStyle = new JButton(PluginServices.getText(this, "select"));
276
                        btnSelStyle.setActionCommand(SELECT_STYLE);
277
                        btnSelStyle.addActionListener(this);
278
                }
279

    
280
                return btnSelStyle;
281
        }
282

    
283

    
284
        private JButton getBtnRemoveField() {
285
                if (btnRemoveField == null) {
286
                        btnRemoveField = new JButton(PluginServices.getText(this, "remove"));
287
                        btnRemoveField.setActionCommand(DELETE_FIELD);
288
                        btnRemoveField.addActionListener(this);
289
                }
290

    
291
                return btnRemoveField;
292
        }
293

    
294
        private JButton getBtnAddField() {
295
                if (btnAddField == null) {
296
                        btnAddField = new JButton(PluginServices.getText(this, "add"));
297
                        btnAddField.setActionCommand(ADD_FIELD);
298
                        btnAddField.addActionListener(this);
299
                }
300

    
301
                return btnAddField;
302
        }
303

    
304
        private JButton getBtnDontUseStyle() {
305
                if (btnDontUseStyle == null) {
306
                        btnDontUseStyle = new JButton(PluginServices.getText(this, "no_style"));
307
                        btnDontUseStyle.setActionCommand(CLEAR_STYLE);
308
                        btnDontUseStyle.addActionListener(this);
309
                }
310

    
311
                return btnDontUseStyle;
312
        }
313

    
314
        private JTable getTableFields() {
315
                if (tblExpressions == null) {
316
                        tblExpressions = new JTable();
317
                        tblExpressions.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
318
                }
319

    
320
                return tblExpressions;
321
        }
322

    
323
        private void setComponentEnabled(Component c, boolean b) {
324
                if (c instanceof JComponent) {
325
                        JComponent c1 = (JComponent) c;
326
                        for (int i = 0; i < c1.getComponentCount(); i++) {
327
                                setComponentEnabled(c1.getComponent(i), b);
328
                        }
329
                }
330
                c.setEnabled(b);
331
        }
332

    
333

    
334

    
335
        public void setLabelClass(LabelClass labelClass) {
336
                if (labelClass == null)
337
                        return;
338

    
339
                lc = labelClass;
340
                clonedClass = LabelingFactory
341
                .createLabelClassFromXML(lc.getXMLEntity());
342

    
343
                labelPreview.setLabelClass(clonedClass);
344
                if (!clonedClass.isUseSqlQuery()) {
345
                        rdBtnAllFeatures.setSelected(true);
346
                        txtSQL.setText("");
347
                } else {
348
                        rdBtnFilteredFeatures.setSelected(true);
349
                        txtSQL.setText(clonedClass.getSQLQuery());
350
                }
351

    
352
                chkLabelFeatures.setSelected(clonedClass.isVisible());
353
                rdBtnFilteredFeatures.setSelected(clonedClass.isUseSqlQuery());
354
                rdBtnAllFeatures.setSelected(!clonedClass.isUseSqlQuery());
355
                ((StylePreviewer) styPreviewer).setStyle(clonedClass.getLabelStyle());
356
                txtName.setText(clonedClass.getName());
357
                String expr = lc.getStringLabelExpression();
358

    
359

    
360
                String EOExpr = LabelExpressionParser.tokenFor(LabelExpressionParser.EOEXPR);
361

    
362
                if (expr == null)
363
                        expr = EOExpr;
364

    
365

    
366
                expr = expr.trim();
367
                if (!expr.endsWith(EOExpr)) {
368
                        throw new Error("Invalid expression. Missing EOExpr token ("+EOExpr+").\n"+expr);
369
                }
370
                expr = expr.substring(0, expr.length()-1);
371

    
372
                expr = expr.trim();
373

    
374
                textStyle.setModel(
375
                                lc.getTextSymbol(),
376
                                lc.getUnit(),
377
                                lc.getReferenceSystem());
378

    
379

    
380

    
381

    
382
                getTableFields().setModel(new FieldTableExpressions(lc.getLabelExpressions()));
383
                TableColumnModel colMod = getTableFields().getColumnModel();
384
                colMod.getColumn(0).setPreferredWidth(100);
385
                colMod.getColumn(0).setWidth(100);
386
                colMod.getColumn(1).setPreferredWidth(517);
387
                repaint();
388

    
389
                actionPerformed(new ActionEvent(this, 0, null));
390

    
391
        }
392

    
393

    
394
        public WindowInfo getWindowInfo() {
395
                WindowInfo wi = new WindowInfo(WindowInfo.MODALDIALOG
396
                                | WindowInfo.RESIZABLE);
397
                wi.setTitle(PluginServices.getText(this, "label_class_properties"));
398
                wi.setWidth(getPreferredSize().width + 8);
399
                wi.setHeight(getPreferredSize().height);
400
                return wi;
401
        }
402

    
403

    
404
        public void actionPerformed(ActionEvent e) {
405
                setComponentEnabled(sqlPnl, rdBtnFilteredFeatures.isSelected());
406
                applySettings();
407
                if ("OK".equals(e.getActionCommand())) {
408
                        clonedClass.setUnit(textStyle.getUnit());
409
                        clonedClass.setReferenceSystem(textStyle.getReferenceSystem());
410
                        clonedClass.setTextSymbol(textStyle.getTextSymbol());
411
                        lc = clonedClass;
412
                        try {
413
                                PluginServices.getMDIManager().closeWindow(this);
414
                        } catch (Exception ex) {
415
                                // this only happens when running this as stand-alone app
416
                                // from main method;
417
                                ex.printStackTrace();
418
                        }
419
                } else if ("CANCEL".equals(e.getActionCommand())) {
420
                        try {
421
                                PluginServices.getMDIManager().closeWindow(this);
422
                        } catch (Exception ex) {
423
                                // this only happens when running this as stand-alone app
424
                                // from main method;
425
                                ex.printStackTrace();
426
                        }
427
                } else if (CLEAR_STYLE.equals(e.getActionCommand())) {
428
                        clonedClass.setLabelStyle(null);
429
//                        styPreviewer.setStyle(null);
430
                        ((StylePreviewer) styPreviewer).setStyle(null);
431
                } else if (TEST_SQL.equals(e.getActionCommand())) {
432
                        System.out.println(TEST_SQL);
433
                } else if (DELETE_FIELD.equals(e.getActionCommand())) {
434
                        int[] rowInd = getTableFields().getSelectedRows();
435
                        for (int i = rowInd.length-1; i >= 0 ; i--) {
436
                                delField(rowInd[i]);
437
                        }
438
                        clonedClass.setLabelExpressions(((FieldTableExpressions) getTableFields().getModel()).getExpression());
439
                        setLabelClass(clonedClass);
440
                } else if (ADD_FIELD.equals(e.getActionCommand())) {
441
                        addField();
442
                } else if (SELECT_STYLE.equals(e.getActionCommand())) {
443

    
444
                        IStyle myStyle = ((StylePreviewer)styPreviewer).getStyle();
445
                        StyleSelector stySel = new StyleSelector(
446
                                        myStyle,
447
                                        FShape.TEXT,  new AbstractStyleSelectorFilter(new SimpleLabelStyle()) {
448
                                        });
449

    
450

    
451
                        PluginServices.getMDIManager().addWindow(stySel);
452
                        ILabelStyle sty = (ILabelStyle) stySel.getSelectedObject();
453

    
454
                        if (sty != null) {
455
                                // gather the style and apply to the class
456
                                clonedClass.setLabelStyle(sty);
457
                                clonedClass.setUnit(stySel.getUnit());
458
                                clonedClass.setReferenceSystem(stySel.getReferenceSystem());
459
                                setLabelClass(clonedClass);
460
                        }
461

    
462
//                        styPreviewer.setStyle(sty);
463
                        ((StylePreviewer) styPreviewer).setStyle(sty);
464

    
465
                }else if (e.getSource().equals(rdBtnAllFeatures) || e.getSource().equals(rdBtnFilteredFeatures)){
466
                        clonedClass.setUseSqlQuery(rdBtnFilteredFeatures.isSelected());
467
                }
468

    
469
                repaint();
470
        }
471

    
472
        private void applySettings() {
473
                clonedClass.setVisible(chkLabelFeatures.isSelected());
474
                clonedClass.setName(txtName.getText());
475
                clonedClass.setSQLQuery(txtSQL.getText());
476
                clonedClass.setLabelExpressions(
477
                                ((FieldTableExpressions) getTableFields().
478
                                                getModel()).getExpression());
479
                clonedClass.setTextSymbol(textStyle.getTextSymbol());
480
        }
481

    
482
        private void addField() {
483
                addField("");
484
        }
485

    
486
        private void addField(String fieldExpr) {
487
                FieldTableExpressions m = ((FieldTableExpressions) getTableFields().getModel());
488
                m.addRow(new Object[] { m.getRowCount()+1, fieldExpr });
489
        }
490

    
491
        private void delField(int fieldIndex) {
492
                try {
493
                        ((FieldTableExpressions) getTableFields().getModel()).removeRow(fieldIndex);
494
                } catch (ArrayIndexOutOfBoundsException ex) {}
495
        }
496

    
497

    
498
        public LabelClass getLabelClass() {
499
                return lc;
500
        }
501

    
502

    
503

    
504
        private static final Object[] TABLE_HEADERS = new String[] {
505
                PluginServices.getText(FieldTableExpressions.class, "field_number"),
506
                PluginServices.getText(FieldTableExpressions.class, "label_expression"),
507

    
508
        };
509
        private static String fieldSeparator = LabelExpressionParser.tokenImage[LabelExpressionParser.EOFIELD].replaceAll("\"", "");
510
        private class FieldTableExpressions extends DefaultTableModel {
511
                private static final long serialVersionUID = 2002427714889477770L;
512
                public FieldTableExpressions(String[] expressions) {
513
                        super();
514

    
515
                        if(expressions != null && expressions.length > 0){
516
                                Integer[] aux = new Integer[expressions.length];
517
                                for (int i = 0; i < aux.length; i++) {
518
                                        aux[i] = i+1;
519
                                }
520

    
521
                                Object[][] values = new Object[aux.length][2];
522
                                for (int i = 0; i < values.length; i++) {
523
                                        values[i][0] = aux[i];
524
                                        values[i][1] = expressions[i];
525
                                }
526
                                setDataVector(values, TABLE_HEADERS);
527
                        }
528
                        else{
529
                                Object[][] values = new Object[1][2];
530
                                values[0][0] = 1;
531
                                values[0][1] = "";
532
                                setDataVector(values,TABLE_HEADERS);
533
                        }
534

    
535
                }
536

    
537

    
538
                @Override
539
                public boolean isCellEditable(int row, int column) {
540
//                        System.out.println("FieldTableExpressions.isCellEditable() "+(column == 1));
541
                        return column == 1;
542
                }
543

    
544
                public String[] getExpression() {
545

    
546
                        String[] expressions = new String[getRowCount()];
547

    
548
                        for (int i = 0; i < getRowCount(); i++) {
549
                                expressions[i] = ""+(String) getValueAt(i,1);
550
                        }
551
                        return expressions;
552
                }
553

    
554
        }
555

    
556
//        public static void main(String[] args) {
557
//                JFrame f = new JFrame("Test LabelClassProperties panel");
558
//
559
//                String xmlString =
560
//                        "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" +
561
//                        "<xml-tag xmlns=\"http://www.gvsig.gva.es\">\n" +
562
//                        "    <property key=\"className\" value=\"com.iver.cit.gvsig.fmap.rendering.styling.labeling.LabelClass\"/>\n" +
563
//                        "    <property key=\"isVisible\" value=\"false\"/>\n" +
564
//                        "    <property key=\"name\" value=\"Default\"/>\n" +
565
//                        "    <property key=\"labelExpression\" value=\"[TIPO] : lao39805502232 : Substring([MOTO], 2,2);\"/>\n" +
566
//                        "    <property key=\"unit\" value=\"-1\"/>\n" +
567
//                        "    <property key=\"referenceSystem\" value=\"0\"/>\n" +
568
//                        "    <property key=\"sqlQuery\" value=\"TIPO = 'C'\"/>\n" +
569
//                        "    <property key=\"priority\" value=\"0\"/>\n" +
570
//                        "    <xml-tag>\n" +
571
//                        "        <property key=\"className\" value=\"org.gvsig.symbology.fmap.styles.SimpleLabelStyle\"/>\n" +
572
//                        "        <property key=\"desc\" value=\"Placa Carrer VLC.style\"/>\n" +
573
//                        "        <property key=\"markerPointX\" value=\"0.0\"/>\n" +
574
//                        "        <property key=\"markerPointY\" value=\"0.0\"/>\n" +
575
//                        "        <property key=\"minXArray\" value=\"0.35 ,0.25\"/>\n" +
576
//                        "        <property key=\"minYArray\" value=\"0.15 ,0.5\"/>\n" +
577
//                        "        <property key=\"widthArray\" value=\"0.5 ,0.6\"/>\n" +
578
//                        "        <property key=\"heightArray\" value=\"0.27 ,0.37\"/>\n" +
579
//                        "        <property key=\"id\" value=\"labelStyle\"/>\n" +
580
//                        "        <xml-tag>\n" +
581
//                        "            <property key=\"className\" value=\"org.gvsig.symbology.fmap.styles.RemoteFileStyle\"/>\n" +
582
//                        "            <property key=\"source\" value=\"http://www.boomlapop.com/boomlapop.jpg\"/>\n" +
583
//                        "            <property key=\"desc\"/>\n" +
584
//                        "            <property key=\"id\" value=\"LabelStyle\"/>\n" +
585
//                        "        </xml-tag>\n" +
586
//                        "    </xml-tag>\n" +
587
//                        "    <xml-tag>\n" +
588
//                        "        <property key=\"className\" value=\"com.iver.cit.gvsig.fmap.core.symbols.SimpleTextSymbol\"/>\n" +
589
//                        "        <property key=\"desc\"/>\n" +
590
//                        "        <property key=\"isShapeVisible\" value=\"true\"/>\n" +
591
//                        "        <property key=\"font\" value=\"Arial\"/>\n" +
592
//                        "        <property key=\"fontStyle\" value=\"1\"/>\n" +
593
//                        "        <property key=\"size\" value=\"12\"/>\n" +
594
//                        "        <property key=\"text\" value=\"GeneralLabeling.sample_text\"/>\n" +
595
//                        "        <property key=\"textColor\" value=\"255,255,0,255\"/>\n" +
596
//                        "        <property key=\"unit\" value=\"-1\"/>\n" +
597
//                        "        <property key=\"referenceSystem\" value=\"0\"/>\n" +
598
//                        "        <property key=\"id\" value=\"TextSymbol\"/>\n" +
599
//                        "    </xml-tag>\n" +
600
//                        "</xml-tag>\n" +
601
//                        "";
602
//
603
//                LabelClass lc = null;
604
//                try {
605
//                        XMLEntity xml = new XMLEntity((XmlTag) XmlTag.unmarshal(
606
//                                        XMLEncodingUtils.getReader(new ByteArrayInputStream(xmlString.getBytes()))));
607
//                        lc = new LabelClass();
608
//                        lc.setXMLEntity(xml);
609
//                } catch (Exception e) {
610
//                        e.printStackTrace();
611
//                }
612
//                String[] names = new String[] { "Field1", "Field2", "Field3"        };
613
//                int[] types = new int[] { Types.VARCHAR, Types.INTEGER, Types.DOUBLE };
614
//                final LabelClassProperties lcp = new LabelClassProperties(
615
//                                names, types ) {
616
//                        private static final long serialVersionUID = -1843509415649666459L;
617
//
618
//                        @Override
619
//                        public void actionPerformed(ActionEvent e) {
620
//                                super.actionPerformed(e);
621
//                                if ("OK".equals(e.getActionCommand())) {
622
//                                        System.out.println(getLabelClass().getXMLEntity());
623
//                                }
624
//                        }
625
//                };
626
//                lcp.setLabelClass(lc);
627
//                f.setContentPane(lcp);
628
//                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
629
//                f.pack();
630
//                f.setVisible(true);
631
//
632
//        }
633

    
634
}