Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / gui / styling / SymbolLevelsWindow.java @ 31631

History | View | Annotate | Download (20.7 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.app.gui.styling;
42

    
43
import java.awt.BorderLayout;
44
import java.awt.Color;
45
import java.awt.Component;
46
import java.awt.FlowLayout;
47
import java.awt.Font;
48
import java.awt.Graphics;
49
import java.awt.Graphics2D;
50
import java.awt.Point;
51
import java.awt.Rectangle;
52
import java.awt.event.ActionEvent;
53
import java.awt.event.ActionListener;
54
import java.awt.event.MouseEvent;
55
import java.awt.event.MouseListener;
56
import java.awt.geom.GeneralPath;
57
import java.util.Hashtable;
58
import java.util.Iterator;
59

    
60
import javax.swing.BorderFactory;
61
import javax.swing.BoxLayout;
62
import javax.swing.Icon;
63
import javax.swing.JButton;
64
import javax.swing.JCheckBox;
65
import javax.swing.JComponent;
66
import javax.swing.JPanel;
67
import javax.swing.JScrollPane;
68
import javax.swing.JTable;
69
import javax.swing.border.EtchedBorder;
70
import javax.swing.event.ChangeEvent;
71
import javax.swing.table.DefaultTableModel;
72
import javax.swing.table.TableCellEditor;
73
import javax.swing.table.TableColumn;
74
import javax.swing.table.TableModel;
75

    
76
import org.gvsig.andami.PluginServices;
77
import org.gvsig.andami.ui.mdiManager.IWindow;
78
import org.gvsig.andami.ui.mdiManager.WindowInfo;
79
import org.gvsig.app.project.documents.gui.TableSymbolCellRenderer;
80
import org.gvsig.fmap.mapcontext.MapContextLocator;
81
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort;
82
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
83
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
84
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
85
import org.gvsig.gui.beans.AcceptCancelPanel;
86
import org.gvsig.gui.beans.swing.JBlank;
87
import org.gvsig.gui.beans.swing.celleditors.BooleanTableCellEditor;
88
import org.gvsig.gui.beans.swing.celleditors.IntegerTableCellEditor;
89
import org.gvsig.gui.beans.swing.cellrenderers.BooleanTableCellRenderer;
90
import org.gvsig.gui.beans.swing.cellrenderers.NumberTableCellRenderer;
91

    
92

    
93
/**
94
 * Creates a panel to specify an order for the symbols of a map. This order
95
 * is important when the map is going to be painted because, apart from that
96
 * the waste of time can be less, the final representation of the map will
97
 * depend on this order.
98
 *
99
 *
100
 * @author jaume dominguez faus - jaume.dominguez@iver.es
101
 */
102
public class SymbolLevelsWindow extends JPanel implements IWindow, ActionListener {
103
        private static final long serialVersionUID = 3241898997869313055L;
104
        private static final int DESCRIPTION_COLUMN_INDEX = 1;
105
        private static final int SYMBOL_COLUMN_INDEX = 0;
106
        private static final int MERGE_COLUMN_INDEX = 3;
107
        private static final int JOIN_COLUMN_INDEX = 2;
108
        private static final int FIRST_LEVEL_COLUMN_INDEX = 2;
109
        private static final String[] defaultHeaders = new String[] {
110
                PluginServices.getText(SymbolLevelsWindow.class, "symbol"),
111
                PluginServices.getText(SymbolLevelsWindow.class, "description"),
112
                PluginServices.getText(SymbolLevelsWindow.class, "join"),
113
                PluginServices.getText(SymbolLevelsWindow.class, "merge"),
114
        };
115
        private static final int DEFAULT_VIEW = 0;
116
        private static final int ADVANCED_VIEW = 1;
117
        private static int viewMode = ADVANCED_VIEW;
118
        private JCheckBox chkSpecifyDrawOrder = null;
119
        private JPanel pnlCenter = null;
120
        private JScrollPane srclLevels = null;
121
        private JTable tblLevels = null;
122
        private JButton btnUp = null;
123
        private JButton btnDown;
124
        private JPanel pnlSouth = null;
125
        private String[] advancedHeaders;
126
        private JButton btnSwitchView;
127
        private ZSort zSort;
128
        private SymbolSummary summary = new SymbolSummary();
129

    
130
        private ActionListener action = new ActionListener() {
131
                public void actionPerformed(ActionEvent e) {
132
                        String actionCommand = e.getActionCommand();
133
                        if ("OK".equals(actionCommand)) {
134
                                tblLevels.editingStopped(new ChangeEvent(tblLevels));
135
                                applyValues();
136
                        }
137

    
138
                        PluginServices.getMDIManager().closeWindow(SymbolLevelsWindow.this);
139

    
140
                }
141
        };
142

    
143
        public WindowInfo getWindowInfo() {
144
                WindowInfo wi = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MODALDIALOG);
145
                wi.setTitle(PluginServices.getText(this, "symbol_levels"));
146
                wi.setWidth(getWidth()+10);
147
                wi.setHeight(getHeight());
148
                return wi;
149
        }
150
        /**
151
         * Completes the main table of the panel with the symbols contained in the
152
         * legend of the map.
153
         *
154
         */
155
        private void applyValues() {
156

    
157
                // update symbol order
158
                TableModel model = tblLevels.getModel();
159

    
160

    
161

    
162
                Hashtable<ISymbol, int[] > aTable = new Hashtable<ISymbol, int[]>();
163
                ISymbol[] symbols = new ISymbol[model.getRowCount()];
164
                for (int i = 0; i < symbols.length; i++) {
165
                        symbols[i] = (ISymbol) model.getValueAt(i, SYMBOL_COLUMN_INDEX);
166
                        int length = 1;
167
                        if (symbols[i] instanceof IMultiLayerSymbol) {
168
                                IMultiLayerSymbol mlSym = (IMultiLayerSymbol) symbols[i];
169
                                length = mlSym.getLayerCount();
170
                        }
171

    
172
                        int[] symbolLevels = new int[length];
173
                        if (viewMode == DEFAULT_VIEW) {
174
                                // default view (JOIN and MERGE)
175
                                if (symbols[i] instanceof IMultiLayerSymbol) {
176
                                        boolean join = ((Boolean) model.getValueAt(i, JOIN_COLUMN_INDEX)).booleanValue();
177
                                        boolean merge= ((Boolean) model.getValueAt(i, MERGE_COLUMN_INDEX)).booleanValue();
178
                                        boolean needToJoin = true;
179
                                        if (merge && i>0) {
180
                                                int j=0;
181
                                                try {
182
                                                        int[] prevSymbolLevels = aTable.get(symbols[i-1]);
183
                                                        for (j = 0; j < symbolLevels.length; j++) {
184
                                                                symbolLevels[j] = prevSymbolLevels[j];
185
                                                        }
186
                                                } catch (IndexOutOfBoundsException ex) {
187
                                                        /* perfect, no problem
188
                                                         * the previous symbol has different amount of layers
189
                                                         * that is ok because we just have to replicate
190
                                                         * the values of each cell
191
                                                         */
192
                                                        for (; j < symbolLevels.length; j++) {
193
                                                                symbolLevels[j] = symbolLevels[j-1]+1;
194
                                                        }
195
                                                }
196
                                                needToJoin = false;
197
                                        }
198
                                        if (join && needToJoin) {
199
                                                for (int j = 0; j < symbolLevels.length; j++) {
200
                                                        symbolLevels[j] = zSort.getLevelCount()+j+1;
201
                                                }
202
                                        }
203
                                        if (!join && !merge) {
204
                                                for (int j = 0; j < symbolLevels.length; j++) {
205
                                                        symbolLevels[j] = zSort.getLevelCount();
206
                                                }
207
                                        }
208
                                } else {
209
                                        symbolLevels[0] = zSort.getLevelCount();
210
                                }
211
                        } else {
212
                                // ADVANCED VIEW (user may set map levels manually)
213
                                for (int j = 0; j < symbolLevels.length; j++) {
214
                                        symbolLevels[j] = ((Integer) model.getValueAt(i, j+FIRST_LEVEL_COLUMN_INDEX)).intValue();
215
                                }
216
                        }
217

    
218
                        aTable.put(symbols[i], symbolLevels);
219
                }
220

    
221
                Iterator<ISymbol> it = aTable.keySet().iterator();
222
                while (it.hasNext()) {
223
                        ISymbol sym = it.next();
224
                        zSort.setLevels(sym, aTable.get(sym));
225
                }
226

    
227
                zSort.setUsingZSort(getChkSpecifyDrawOrder().isSelected());
228
        }
229

    
230
        public SymbolLevelsWindow(ZSort zSort) {
231
                super();
232
                initialize();
233
                setModel(zSort);
234
                quitaEsteMetodo();
235
                tblLevels.setRowHeight(23);
236
        }
237
        private void quitaEsteMetodo() {
238
                getBtnSwitchView().setEnabled(false);
239
                getBtnDown().setEnabled(false);
240
                getBtnUp().setEnabled(false);
241
        }
242
        /**
243
         * Sets the model
244
         * @param plan ZSort
245
         */
246

    
247
        public void setModel(ZSort plan) {
248
                advancedHeaders = new String[FIRST_LEVEL_COLUMN_INDEX
249
                                             +plan.getTopLevelIndexAllowed() ];
250
                advancedHeaders[SYMBOL_COLUMN_INDEX] = defaultHeaders[SYMBOL_COLUMN_INDEX];
251
                advancedHeaders[DESCRIPTION_COLUMN_INDEX] = defaultHeaders[DESCRIPTION_COLUMN_INDEX];
252
                for (int i = 2; i < advancedHeaders.length; i++) {
253
                        advancedHeaders[i] = String.valueOf(i-1);
254
                }
255
                this.zSort = plan;
256
                getChkSpecifyDrawOrder().setSelected(plan.isUsingZSort());
257
                initTableContents(getTblLevels(), plan, viewMode);
258
        }
259
        /**
260
         * Initializes the table that it is showed in the panel where the user can
261
         * see the different symbols of the legend and has options to specify the
262
         * level for each one, merge and so on.
263
         *
264
         * @param table
265
         * @param zSort
266
         * @param mode
267
         */
268
        private void initTableContents(JTable table, ZSort zSort, int mode) {
269
                DefaultTableModel model = new DefaultTableModel();
270
                Object[][] dataVector = null;
271
                ISymbol[] syms = zSort.getSymbols();
272
                String[] labels = zSort.getDescriptions();
273

    
274
                if (mode == DEFAULT_VIEW) {
275
                        // default view (JOIN and MERGE)
276
                        dataVector = new Object[syms.length][syms.length];
277
                        for (int i = 0; i < syms.length; i++) {
278
                                dataVector[i] = new Object[defaultHeaders.length];
279
                                dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i];
280
                                dataVector[i][DESCRIPTION_COLUMN_INDEX] = labels[i];
281
                                if (syms[i] instanceof IMultiLayerSymbol) {
282
                                        boolean joined = true;
283
                                        int[] levels = zSort.getLevels(syms[i]);
284
                                        if(levels != null){
285
                                                for (int j = 0; j < levels.length; j++) {
286
                                                        if (joined) {
287
                                                                joined = levels[j] != levels[j+1];
288
                                                        }
289
                                                }
290
                                        }
291

    
292

    
293
                                        boolean merged = true;
294
                                        if (i<syms.length-1) {
295
                                                for (int j = 0; joined && j < levels.length; j++) {
296
                                                        // must be joined to be merged
297
                                                        ISymbol nextSymbol = syms[i+1];
298
                                                        int[] nextLevels = zSort.getLevels(nextSymbol);
299
                                                        if(nextLevels != null){
300
                                                                if (nextSymbol instanceof IMultiLayerSymbol) {
301
                                                                        if (j<nextLevels.length) {
302
                                                                                merged = levels[j] == nextLevels[j];
303
                                                                        }
304
                                                                } else {
305
                                                                        merged = levels[0] == nextLevels[0];
306
                                                                }
307
                                                        }
308
                                                }
309
                                                if (!merged) {
310
                                                        break;
311
                                                }
312
                                        }
313
                                        if (!joined) {
314
                                                merged = false;
315
                                        }
316
                                        dataVector[i][JOIN_COLUMN_INDEX] = new Boolean(joined);
317
                                        dataVector[i][MERGE_COLUMN_INDEX] = new Boolean(merged);
318
                                }
319
                        }
320

    
321
                        model.setDataVector(dataVector, defaultHeaders);
322
                        table.setModel(model);
323
                        TableColumn col = table.getColumnModel().getColumn(JOIN_COLUMN_INDEX);
324
                        col.setCellRenderer(new BooleanTableCellRenderer(true));
325
                        col.setCellEditor(new BooleanTableCellEditor(table));
326
                        col = table.getColumnModel().getColumn(MERGE_COLUMN_INDEX);
327
                        col.setCellRenderer(new BooleanTableCellRenderer(true));
328
                        col.setCellEditor(new BooleanTableCellEditor(table));
329
                } else {
330
                        // advanced view (user may input the map level manually)
331
                        dataVector = new Object[syms.length][
332
                                                             FIRST_LEVEL_COLUMN_INDEX + /* this is the first column that
333
                                                              * contains a level for the symbol
334
                                                              */
335

    
336
                                                             zSort.getTopLevelIndexAllowed() + /* according to the set of
337
                                                              * symbols this will get the
338
                                                              * max level reachable
339
                                                              */
340
                                                             1 /* plus 1 to get a count instead of an index */];
341
                        for (int i = 0; i < syms.length; i++) {
342
                                dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i];
343
                                dataVector[i][DESCRIPTION_COLUMN_INDEX] = labels[i];
344
                                if (syms[i] instanceof IMultiLayerSymbol) {
345
                                        int[] levels = zSort.getLevels(syms[i]);
346

    
347
                                        for (int j = 0; j < levels.length; j++) {
348
                                                dataVector[i][j+FIRST_LEVEL_COLUMN_INDEX] = levels[j];
349
                                        }
350
                                } else {
351
                                        dataVector[i][FIRST_LEVEL_COLUMN_INDEX] = new Integer(zSort.getLevels(syms[i])[0]);
352
                                }
353
                        }
354

    
355
                        model.setDataVector(dataVector, advancedHeaders);
356
                        table.setModel(model);
357
                        for (int j = FIRST_LEVEL_COLUMN_INDEX; j < model.getColumnCount(); j++) {
358

    
359
                                table.getColumnModel().getColumn(j).setCellRenderer(new NumberTableCellRenderer(true, false));
360
                                table.getColumnModel().getColumn(j).setCellEditor(new IntegerTableCellEditor());
361
                        }
362
                }
363

    
364
                TableSymbolCellRenderer symbolCellRenderer = new TableSymbolCellRenderer(true) {
365
                        private static final long serialVersionUID = 5603529641148869112L;
366

    
367
                        { // Object static initialize block
368

    
369
                                preview = new SymbolPreviewer() {
370
                                        private static final long serialVersionUID = 7262380340075167043L;
371
                                        private Icon downIcon = new Icon(){
372
                                                public int getIconHeight() { return 7; }
373
                                                public int getIconWidth() { return 7; }
374
                                                public void paintIcon(Component c, Graphics g, int x, int y) {
375
                                                        Graphics2D g2 = (Graphics2D) g;
376
                                                        g2.setColor(Color.GRAY);
377
                                                        g2.translate(x + c.getWidth()-getIconWidth()*2, y + c.getHeight()-getIconHeight()*2);
378
                                                        GeneralPath gp = new GeneralPath();
379
                                                        gp.moveTo(0, 0);
380
                                                        gp.lineTo(getIconWidth()/2, getIconHeight()-1);
381
                                                        gp.lineTo(getIconWidth()-1, 0);
382
                                                        g2.fill(gp);
383
                                                        g2.translate(-(x + c.getWidth()-getIconWidth()*2), -(y + c.getHeight()-getIconHeight()*2));
384
                                                }
385
                                        };
386
                                        @Override
387
                                        public void paint(Graphics g) {
388
                                                super.paint(g);
389
                                                if (getSymbol() instanceof IMultiLayerSymbol) {
390
                                                        downIcon.paintIcon(this, g, 0, 0);
391
                                                }
392
                                        }
393
                                };
394

    
395
                        } // Object static initialize block
396
                };
397
                TableColumn col = table.getColumnModel().getColumn(SYMBOL_COLUMN_INDEX);
398
                col.setCellRenderer(symbolCellRenderer);
399
        }
400

    
401
        private void initialize() {
402
                this.setLayout(new BorderLayout(15, 15));
403
                this.setSize(564, 344);
404

    
405
                this.add(getChkSpecifyDrawOrder(), BorderLayout.NORTH);
406
                this.add(new JBlank(20, 20));
407
                this.add(getPnlCenter(), BorderLayout.CENTER);
408
                this.add(getPnlSouth(), BorderLayout.SOUTH);
409
                tblLevels.addMouseListener(new MouseListener() {
410
                        public void mouseReleased(MouseEvent e) { }
411
                        public void mouseClicked(MouseEvent e)  { }
412
                        public void mouseEntered(MouseEvent e)  { }
413
                        public void mouseExited(MouseEvent e)  {
414
                                summary.sym = null;
415
                                repaint();
416
        }
417

    
418
                        public void mousePressed(MouseEvent e) {
419
                                Point where = e.getPoint();
420
                                int whereX = where.x;
421
                                int whereY = where.y;
422
                                Rectangle bounds = tblLevels.getBounds();
423
                                /*
424
                                 * calculate the right border x-position of the symbol
425
                                 * column
426
                                 */
427
                                int rightEdge = 0;
428
                                for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) {
429
                                        rightEdge += tblLevels.getColumnModel().getColumn(i).getWidth();
430
                                }
431
                                if (whereX >= bounds.x &&
432
                                        whereX <= rightEdge + bounds.x &&
433
                                        whereY >= bounds.y &&
434
                                        whereY <= bounds.height + bounds.y) {
435
                                        int rowHeight = tblLevels.getRowHeight();
436
                                        int rowClicked = (whereY - bounds.y) / rowHeight;
437
                                        ISymbol sym = (ISymbol) tblLevels.
438
                                                                                        getModel().
439
                                                                                        getValueAt(
440
                                                                                                rowClicked,
441
                                                                                                SYMBOL_COLUMN_INDEX);
442
                                        if (sym instanceof IMultiLayerSymbol) {
443
                                                summary.sym = (IMultiLayerSymbol) sym;
444
                                                summary.rowIndex = rowClicked;
445
                                        } else {
446
                                                summary.sym = null;
447
                                        }
448
                                        repaint();
449
                                }
450
                        }
451

    
452
                });
453

    
454
        }
455

    
456
        private JCheckBox getChkSpecifyDrawOrder() {
457
                if (chkSpecifyDrawOrder == null) {
458
                        chkSpecifyDrawOrder = new JCheckBox("<html><b>"+
459
                                        PluginServices.getText(this, "draw_symbols_in_specified_order")
460
                                        +"</b></html>");
461
                        chkSpecifyDrawOrder.addActionListener(this);
462
                }
463
                return chkSpecifyDrawOrder;
464
        }
465

    
466

    
467
        private JPanel getPnlCenter() {
468
                if (pnlCenter == null) {
469
                        pnlCenter = new JPanel();
470
                        pnlCenter.setLayout(new BorderLayout(0, 15));
471
                        pnlCenter.add(getSrclLevels(), BorderLayout.CENTER);
472
                        pnlCenter.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
473
                        JPanel aux = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 15));
474
                        JPanel pnlButtons = new JPanel();
475
                        pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.Y_AXIS));
476
                        pnlButtons.add(new JBlank(1, 70));
477
                        pnlButtons.add(getBtnUp());
478
                        pnlButtons.add(new JBlank(1, 10));
479
                        pnlButtons.add(getBtnDown());
480
                        pnlButtons.setVisible(false);
481
                        aux.add(pnlButtons);
482
                        pnlCenter.add(aux, BorderLayout.EAST);
483

    
484
                }
485
                pnlCenter.setEnabled(getChkSpecifyDrawOrder().isSelected());
486
                return pnlCenter;
487
        }
488

    
489
        private JScrollPane getSrclLevels() {
490
                if (srclLevels == null) {
491
                        srclLevels = new JScrollPane();
492
                        srclLevels.setViewportView(getTblLevels());
493
                }
494
                srclLevels.setEnabled(getChkSpecifyDrawOrder().isSelected());
495
                return srclLevels;
496
        }
497

    
498

    
499
        private JTable getTblLevels() {
500
                if (tblLevels == null) {
501
                        tblLevels = new JTable() {
502
                                private static final long serialVersionUID = -1545710722048183232L;
503

    
504
                                @Override
505
                                protected void paintComponent(Graphics g) {
506
                                        super.paintComponent(g);
507
                                        summary.paint((Graphics2D) g);
508
                }
509
                        };
510
                        summary.rowHeight = tblLevels.getRowHeight();
511
                }
512
                tblLevels.setEnabled(getChkSpecifyDrawOrder().isSelected());
513
                return tblLevels;
514
        }
515

    
516

    
517
        private JButton getBtnUp() {
518
                if (btnUp == null) {
519
                        btnUp = new JButton(PluginServices.getIconTheme().get("arrow-up-icono"));
520
                        btnUp.setActionCommand("MOVE_UP");
521
                }
522
                return btnUp;
523
        }
524

    
525
        private JButton getBtnDown() {
526
                if (btnDown == null) {
527
                        btnDown = new JButton(PluginServices.getIconTheme().get("arrow-down-icono"));
528
                        btnDown.setActionCommand("MOVE_DOWN");
529
                }
530
                return btnDown;
531
        }
532

    
533

    
534
        private JPanel getPnlSouth() {
535
                if (pnlSouth == null) {
536
                        pnlSouth = new JPanel(new BorderLayout());
537
                        JPanel aux = new JPanel();
538
                        aux.setLayout(new FlowLayout(FlowLayout.RIGHT));
539
                        aux.add(getBtnSwitchView());
540
                        pnlSouth.add(aux, BorderLayout.NORTH);
541

    
542
                        aux = new JPanel();
543
                        aux.setLayout(new FlowLayout(FlowLayout.RIGHT));
544
                        pnlSouth.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH);
545

    
546
                }
547
                return pnlSouth;
548
        }
549

    
550
        private JButton getBtnSwitchView() {
551
                if (btnSwitchView == null) {
552
                        btnSwitchView = new JButton(
553
                                        (viewMode != DEFAULT_VIEW) ?
554
                                        PluginServices.getText(this, "default_view"):
555
                                        PluginServices.getText(this, "advanced_view")
556
                                        );
557
                        btnSwitchView.addActionListener(this);
558
                        btnSwitchView.setVisible(false);
559
                }
560

    
561
                return btnSwitchView;
562
        }
563

    
564
        public void actionPerformed(ActionEvent e) {
565
                JComponent c = (JComponent) e.getSource();
566
                if (c.equals(getChkSpecifyDrawOrder())) {
567
                        getPnlCenter().setEnabled(getChkSpecifyDrawOrder().isSelected());
568
                        getSrclLevels().setEnabled(getChkSpecifyDrawOrder().isSelected());
569
                        TableCellEditor tce = getTblLevels().getCellEditor();
570
                        if (tce != null){
571
                                tce.stopCellEditing();
572
                        }
573
                        getTblLevels().setEnabled(getChkSpecifyDrawOrder().isSelected());
574
                } else if (c.equals(getBtnSwitchView())) {
575
                        viewMode = (viewMode == ADVANCED_VIEW) ? DEFAULT_VIEW : ADVANCED_VIEW;
576
                        initTableContents(getTblLevels(), zSort, viewMode);
577
                        btnSwitchView.setText((viewMode != DEFAULT_VIEW) ?
578
                                        PluginServices.getText(this, "default_view"):
579
                                        PluginServices.getText(this, "advanced_view"));
580
                }
581
        }
582
        /**
583
         * Gets the ZSort value
584
         *
585
         * @return zSort ZSort
586
         */
587
        public ZSort getZSort() {
588
                return zSort;
589
        }
590

    
591
        private class SymbolSummary {
592
                int witdh;
593
                int rowHeight = 10;
594

    
595
                int rowIndex;
596

    
597
                IMultiLayerSymbol sym;
598

    
599
                void paint(Graphics2D g){
600

    
601
                        if (sym != null) {
602
                                int whereY = (rowHeight*(rowIndex-1) + (int) (rowHeight/0.6));
603
                                int whereX = 0;
604
                                for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) {
605
                                        whereX += tblLevels.getColumnModel().getColumn(i).getWidth();
606
                                }
607
                                whereX -= 40;
608
                                int width = 150;
609
                                int height = Math.max(rowHeight*sym.getLayerCount(), rowHeight);
610
                                Rectangle bounds = new Rectangle(whereX, whereY, width, height);
611
                                g.setColor(new Color(255, 255, 220));
612
                                g.fill(bounds);
613

    
614
                                g.setColor(new Color(255, 230, 20));
615
                                g.draw(bounds);
616

    
617
                                g.setFont(new Font("Arial", Font.BOLD, 10));
618

    
619
                                for (int i = 0; i < sym.getLayerCount(); i++) {
620
                                        g.setColor(Color.black);
621
                                        g.drawString(i+1+":", whereX+5, height + whereY - ( (i*rowHeight) + 5 ));
622
                                        Rectangle rect = new Rectangle(whereX + 20,
623
                                                        height + whereY - ((i+1)*rowHeight) + 3,
624
                                                        width - 20,
625
                                                        rowHeight - 6);
626
                                        try {
627
                                                sym.getLayer(i).drawInsideRectangle(g, null, rect,null);
628
                                        } catch (SymbolDrawingException e) {
629
                                                if (e.getType() == SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS) {
630
                                                        try {
631
                                                                MapContextLocator.getSymbolManager()
632
                                                                                .getWarningSymbol(
633
                                                                                                SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS,
634
                                                                                                "",
635
                                                                                                SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS)
636
                                                                                .drawInsideRectangle(g, null, rect,
637
                                                                                                null);
638
                                                        } catch (SymbolDrawingException e1) {
639
                                                                // IMPOSSIBLE TO REACH THIS
640
                                                        }
641
                                                } else {
642
                                                        // should be unreachable code
643
                                                        throw new Error(PluginServices.getText(this, "symbol_shapetype_mismatch"));
644
                                                }
645
                                        }
646
                                }
647

    
648
                        }
649
                };
650
        }
651

    
652
        public Object getWindowProfile() {
653
                return WindowInfo.DIALOG_PROFILE;
654
        }
655

    
656
}