Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.swing / org.gvsig.symbology.swing.api / src / main / java / org / gvsig / app / gui / styling / SymbolLevelsWindow.java @ 40560

History | View | Annotate | Download (20.2 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.gui.styling;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.Color;
28
import java.awt.Component;
29
import java.awt.FlowLayout;
30
import java.awt.Font;
31
import java.awt.Graphics;
32
import java.awt.Graphics2D;
33
import java.awt.Point;
34
import java.awt.Rectangle;
35
import java.awt.event.ActionEvent;
36
import java.awt.event.ActionListener;
37
import java.awt.event.MouseEvent;
38
import java.awt.event.MouseListener;
39
import java.awt.geom.GeneralPath;
40
import java.util.Hashtable;
41
import java.util.Iterator;
42

    
43
import javax.swing.BorderFactory;
44
import javax.swing.BoxLayout;
45
import javax.swing.Icon;
46
import javax.swing.JButton;
47
import javax.swing.JCheckBox;
48
import javax.swing.JComponent;
49
import javax.swing.JPanel;
50
import javax.swing.JScrollPane;
51
import javax.swing.JTable;
52
import javax.swing.border.EtchedBorder;
53
import javax.swing.event.ChangeEvent;
54
import javax.swing.table.DefaultTableModel;
55
import javax.swing.table.TableCellEditor;
56
import javax.swing.table.TableColumn;
57
import javax.swing.table.TableModel;
58

    
59
import org.gvsig.andami.PluginServices;
60
import org.gvsig.andami.ui.mdiManager.IWindow;
61
import org.gvsig.andami.ui.mdiManager.WindowInfo;
62
import org.gvsig.app.project.documents.gui.TableSymbolCellRenderer;
63
import org.gvsig.fmap.mapcontext.MapContextLocator;
64
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort;
65
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol;
66
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
67
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
68
import org.gvsig.gui.beans.AcceptCancelPanel;
69
import org.gvsig.gui.beans.swing.JBlank;
70
import org.gvsig.gui.beans.swing.celleditors.BooleanTableCellEditor;
71
import org.gvsig.gui.beans.swing.celleditors.IntegerTableCellEditor;
72
import org.gvsig.gui.beans.swing.cellrenderers.BooleanTableCellRenderer;
73
import org.gvsig.gui.beans.swing.cellrenderers.NumberTableCellRenderer;
74
import org.gvsig.i18n.Messages;
75

    
76

    
77
/**
78
 * Creates a panel to specify an order for the symbols of a map. This order
79
 * is important when the map is going to be painted because, apart from that
80
 * the waste of time can be less, the final representation of the map will
81
 * depend on this order.
82
 *
83
 *
84
 * @author jaume dominguez faus - jaume.dominguez@iver.es
85
 */
86
public class SymbolLevelsWindow extends JPanel implements IWindow, ActionListener {
87
        private static final long serialVersionUID = 3241898997869313055L;
88
        private static final int DESCRIPTION_COLUMN_INDEX = 1;
89
        private static final int SYMBOL_COLUMN_INDEX = 0;
90
        private static final int MERGE_COLUMN_INDEX = 3;
91
        private static final int JOIN_COLUMN_INDEX = 2;
92
        private static final int FIRST_LEVEL_COLUMN_INDEX = 2;
93
        private static final String[] defaultHeaders = new String[] {
94
                Messages.getText("symbol"),
95
                Messages.getText("description"),
96
                Messages.getText("join"),
97
                Messages.getText("merge"),
98
        };
99
        private static final int DEFAULT_VIEW = 0;
100
        private static final int ADVANCED_VIEW = 1;
101
        private static int viewMode = ADVANCED_VIEW;
102
        private JCheckBox chkSpecifyDrawOrder = null;
103
        private JPanel pnlCenter = null;
104
        private JScrollPane srclLevels = null;
105
        private JTable tblLevels = null;
106
        private JButton btnUp = null;
107
        private JButton btnDown;
108
        private JPanel pnlSouth = null;
109
        private String[] advancedHeaders;
110
        private JButton btnSwitchView;
111
        private ZSort zSort;
112
        private SymbolSummary summary = new SymbolSummary();
113

    
114
        private ActionListener action = new ActionListener() {
115
                public void actionPerformed(ActionEvent e) {
116
                        String actionCommand = e.getActionCommand();
117
                        if ("OK".equals(actionCommand)) {
118
                                tblLevels.editingStopped(new ChangeEvent(tblLevels));
119
                                applyValues();
120
                        }
121

    
122
                        PluginServices.getMDIManager().closeWindow(SymbolLevelsWindow.this);
123

    
124
                }
125
        };
126

    
127
        public WindowInfo getWindowInfo() {
128
                WindowInfo wi = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MODALDIALOG);
129
                wi.setTitle(Messages.getText("symbol_levels"));
130
                wi.setWidth(getWidth()+10);
131
                wi.setHeight(getHeight());
132
                return wi;
133
        }
134
        /**
135
         * Completes the main table of the panel with the symbols contained in the
136
         * legend of the map.
137
         *
138
         */
139
        private void applyValues() {
140

    
141
                // update symbol order
142
                TableModel model = tblLevels.getModel();
143

    
144

    
145

    
146
                Hashtable<ISymbol, int[] > aTable = new Hashtable<ISymbol, int[]>();
147
                ISymbol[] symbols = new ISymbol[model.getRowCount()];
148
                for (int i = 0; i < symbols.length; i++) {
149
                        symbols[i] = (ISymbol) model.getValueAt(i, SYMBOL_COLUMN_INDEX);
150
                        int length = 1;
151
                        if (symbols[i] instanceof IMultiLayerSymbol) {
152
                                IMultiLayerSymbol mlSym = (IMultiLayerSymbol) symbols[i];
153
                                length = mlSym.getLayerCount();
154
                        }
155

    
156
                        int[] symbolLevels = new int[length];
157
                        if (viewMode == DEFAULT_VIEW) {
158
                                // default view (JOIN and MERGE)
159
                                if (symbols[i] instanceof IMultiLayerSymbol) {
160
                                        boolean join = ((Boolean) model.getValueAt(i, JOIN_COLUMN_INDEX)).booleanValue();
161
                                        boolean merge= ((Boolean) model.getValueAt(i, MERGE_COLUMN_INDEX)).booleanValue();
162
                                        boolean needToJoin = true;
163
                                        if (merge && i>0) {
164
                                                int j=0;
165
                                                try {
166
                                                        int[] prevSymbolLevels = aTable.get(symbols[i-1]);
167
                                                        for (j = 0; j < symbolLevels.length; j++) {
168
                                                                symbolLevels[j] = prevSymbolLevels[j];
169
                                                        }
170
                                                } catch (IndexOutOfBoundsException ex) {
171
                                                        /* perfect, no problem
172
                                                         * the previous symbol has different amount of layers
173
                                                         * that is ok because we just have to replicate
174
                                                         * the values of each cell
175
                                                         */
176
                                                        for (; j < symbolLevels.length; j++) {
177
                                                                symbolLevels[j] = symbolLevels[j-1]+1;
178
                                                        }
179
                                                }
180
                                                needToJoin = false;
181
                                        }
182
                                        if (join && needToJoin) {
183
                                                for (int j = 0; j < symbolLevels.length; j++) {
184
                                                        symbolLevels[j] = zSort.getLevelCount()+j+1;
185
                                                }
186
                                        }
187
                                        if (!join && !merge) {
188
                                                for (int j = 0; j < symbolLevels.length; j++) {
189
                                                        symbolLevels[j] = zSort.getLevelCount();
190
                                                }
191
                                        }
192
                                } else {
193
                                        symbolLevels[0] = zSort.getLevelCount();
194
                                }
195
                        } else {
196
                                // ADVANCED VIEW (user may set map levels manually)
197
                                for (int j = 0; j < symbolLevels.length; j++) {
198
                                        symbolLevels[j] = ((Integer) model.getValueAt(i, j+FIRST_LEVEL_COLUMN_INDEX)).intValue();
199
                                }
200
                        }
201

    
202
                        aTable.put(symbols[i], symbolLevels);
203
                }
204

    
205
                Iterator<ISymbol> it = aTable.keySet().iterator();
206
                while (it.hasNext()) {
207
                        ISymbol sym = it.next();
208
                        zSort.setLevels(sym, aTable.get(sym));
209
                }
210

    
211
                zSort.setUsingZSort(getChkSpecifyDrawOrder().isSelected());
212
        }
213

    
214
        public SymbolLevelsWindow(ZSort zSort) {
215
                super();
216
                initialize();
217
                setModel(zSort);
218
                quitaEsteMetodo();
219
                tblLevels.setRowHeight(23);
220
        }
221
        private void quitaEsteMetodo() {
222
                getBtnSwitchView().setEnabled(false);
223
                getBtnDown().setEnabled(false);
224
                getBtnUp().setEnabled(false);
225
        }
226
        /**
227
         * Sets the model
228
         * @param plan ZSort
229
         */
230

    
231
        public void setModel(ZSort plan) {
232
                advancedHeaders = new String[FIRST_LEVEL_COLUMN_INDEX
233
                                             +plan.getTopLevelIndexAllowed() ];
234
                advancedHeaders[SYMBOL_COLUMN_INDEX] = defaultHeaders[SYMBOL_COLUMN_INDEX];
235
                advancedHeaders[DESCRIPTION_COLUMN_INDEX] = defaultHeaders[DESCRIPTION_COLUMN_INDEX];
236
                for (int i = 2; i < advancedHeaders.length; i++) {
237
                        advancedHeaders[i] = String.valueOf(i-1);
238
                }
239
                this.zSort = plan;
240
                getChkSpecifyDrawOrder().setSelected(plan.isUsingZSort());
241
                initTableContents(getTblLevels(), plan, viewMode);
242
        }
243
        /**
244
         * Initializes the table that it is showed in the panel where the user can
245
         * see the different symbols of the legend and has options to specify the
246
         * level for each one, merge and so on.
247
         *
248
         * @param table
249
         * @param zSort
250
         * @param mode
251
         */
252
        private void initTableContents(JTable table, ZSort zSort, int mode) {
253
                DefaultTableModel model = new DefaultTableModel();
254
                Object[][] dataVector = null;
255
                ISymbol[] syms = zSort.getSymbols();
256
                String[] labels = zSort.getDescriptions();
257

    
258
                if (mode == DEFAULT_VIEW) {
259
                        // default view (JOIN and MERGE)
260
                        dataVector = new Object[syms.length][syms.length];
261
                        for (int i = 0; i < syms.length; i++) {
262
                                dataVector[i] = new Object[defaultHeaders.length];
263
                                dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i];
264
                                dataVector[i][DESCRIPTION_COLUMN_INDEX] = labels[i];
265
                                if (syms[i] instanceof IMultiLayerSymbol) {
266
                                        boolean joined = true;
267
                                        int[] levels = zSort.getLevels(syms[i]);
268
                                        if(levels != null){
269
                                                for (int j = 0; j < levels.length; j++) {
270
                                                        if (joined) {
271
                                                                joined = levels[j] != levels[j+1];
272
                                                        }
273
                                                }
274
                                        }
275

    
276

    
277
                                        boolean merged = true;
278
                                        if (i<syms.length-1) {
279
                                                for (int j = 0; joined && j < levels.length; j++) {
280
                                                        // must be joined to be merged
281
                                                        ISymbol nextSymbol = syms[i+1];
282
                                                        int[] nextLevels = zSort.getLevels(nextSymbol);
283
                                                        if(nextLevels != null){
284
                                                                if (nextSymbol instanceof IMultiLayerSymbol) {
285
                                                                        if (j<nextLevels.length) {
286
                                                                                merged = levels[j] == nextLevels[j];
287
                                                                        }
288
                                                                } else {
289
                                                                        merged = levels[0] == nextLevels[0];
290
                                                                }
291
                                                        }
292
                                                }
293
                                                if (!merged) {
294
                                                        break;
295
                                                }
296
                                        }
297
                                        if (!joined) {
298
                                                merged = false;
299
                                        }
300
                                        dataVector[i][JOIN_COLUMN_INDEX] = new Boolean(joined);
301
                                        dataVector[i][MERGE_COLUMN_INDEX] = new Boolean(merged);
302
                                }
303
                        }
304

    
305
                        model.setDataVector(dataVector, defaultHeaders);
306
                        table.setModel(model);
307
                        TableColumn col = table.getColumnModel().getColumn(JOIN_COLUMN_INDEX);
308
                        col.setCellRenderer(new BooleanTableCellRenderer(true));
309
                        col.setCellEditor(new BooleanTableCellEditor(table));
310
                        col = table.getColumnModel().getColumn(MERGE_COLUMN_INDEX);
311
                        col.setCellRenderer(new BooleanTableCellRenderer(true));
312
                        col.setCellEditor(new BooleanTableCellEditor(table));
313
                } else {
314
                        // advanced view (user may input the map level manually)
315
                        dataVector = new Object[syms.length][
316
                                                             FIRST_LEVEL_COLUMN_INDEX + /* this is the first column that
317
                                                              * contains a level for the symbol
318
                                                              */
319

    
320
                                                             zSort.getTopLevelIndexAllowed() + /* according to the set of
321
                                                              * symbols this will get the
322
                                                              * max level reachable
323
                                                              */
324
                                                             1 /* plus 1 to get a count instead of an index */];
325
                        for (int i = 0; i < syms.length; i++) {
326
                                dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i];
327
                                dataVector[i][DESCRIPTION_COLUMN_INDEX] = labels[i];
328
                                if (syms[i] instanceof IMultiLayerSymbol) {
329
                                        int[] levels = zSort.getLevels(syms[i]);
330

    
331
                                        for (int j = 0; j < levels.length; j++) {
332
                                                dataVector[i][j+FIRST_LEVEL_COLUMN_INDEX] = levels[j];
333
                                        }
334
                                } else {
335
                                        dataVector[i][FIRST_LEVEL_COLUMN_INDEX] = new Integer(zSort.getLevels(syms[i])[0]);
336
                                }
337
                        }
338

    
339
                        model.setDataVector(dataVector, advancedHeaders);
340
                        table.setModel(model);
341
                        for (int j = FIRST_LEVEL_COLUMN_INDEX; j < model.getColumnCount(); j++) {
342

    
343
                                table.getColumnModel().getColumn(j).setCellRenderer(new NumberTableCellRenderer(true, false));
344
                                table.getColumnModel().getColumn(j).setCellEditor(new IntegerTableCellEditor());
345
                        }
346
                }
347

    
348
                TableSymbolCellRenderer symbolCellRenderer = new TableSymbolCellRenderer(true) {
349
                        private static final long serialVersionUID = 5603529641148869112L;
350

    
351
                        { // Object static initialize block
352

    
353
                                preview = new SymbolPreviewer() {
354
                                        private static final long serialVersionUID = 7262380340075167043L;
355
                                        private Icon downIcon = new Icon(){
356
                                                public int getIconHeight() { return 7; }
357
                                                public int getIconWidth() { return 7; }
358
                                                public void paintIcon(Component c, Graphics g, int x, int y) {
359
                                                        Graphics2D g2 = (Graphics2D) g;
360
                                                        g2.setColor(Color.GRAY);
361
                                                        g2.translate(x + c.getWidth()-getIconWidth()*2, y + c.getHeight()-getIconHeight()*2);
362
                                                        GeneralPath gp = new GeneralPath();
363
                                                        gp.moveTo(0, 0);
364
                                                        gp.lineTo(getIconWidth()/2, getIconHeight()-1);
365
                                                        gp.lineTo(getIconWidth()-1, 0);
366
                                                        g2.fill(gp);
367
                                                        g2.translate(-(x + c.getWidth()-getIconWidth()*2), -(y + c.getHeight()-getIconHeight()*2));
368
                                                }
369
                                        };
370
                                        @Override
371
                                        public void paint(Graphics g) {
372
                                                super.paint(g);
373
                                                if (getSymbol() instanceof IMultiLayerSymbol) {
374
                                                        downIcon.paintIcon(this, g, 0, 0);
375
                                                }
376
                                        }
377
                                };
378

    
379
                        } // Object static initialize block
380
                };
381
                TableColumn col = table.getColumnModel().getColumn(SYMBOL_COLUMN_INDEX);
382
                col.setCellRenderer(symbolCellRenderer);
383
        }
384

    
385
        private void initialize() {
386
                this.setLayout(new BorderLayout(15, 15));
387
                this.setSize(564, 344);
388

    
389
                this.add(getChkSpecifyDrawOrder(), BorderLayout.NORTH);
390
                this.add(new JBlank(20, 20));
391
                this.add(getPnlCenter(), BorderLayout.CENTER);
392
                this.add(getPnlSouth(), BorderLayout.SOUTH);
393
                tblLevels.addMouseListener(new MouseListener() {
394
                        public void mouseReleased(MouseEvent e) { }
395
                        public void mouseClicked(MouseEvent e)  { }
396
                        public void mouseEntered(MouseEvent e)  { }
397
                        public void mouseExited(MouseEvent e)  {
398
                                summary.sym = null;
399
                                repaint();
400
        }
401

    
402
                        public void mousePressed(MouseEvent e) {
403
                                Point where = e.getPoint();
404
                                int whereX = where.x;
405
                                int whereY = where.y;
406
                                Rectangle bounds = tblLevels.getBounds();
407
                                /*
408
                                 * calculate the right border x-position of the symbol
409
                                 * column
410
                                 */
411
                                int rightEdge = 0;
412
                                for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) {
413
                                        rightEdge += tblLevels.getColumnModel().getColumn(i).getWidth();
414
                                }
415
                                if (whereX >= bounds.x &&
416
                                        whereX <= rightEdge + bounds.x &&
417
                                        whereY >= bounds.y &&
418
                                        whereY <= bounds.height + bounds.y) {
419
                                        int rowHeight = tblLevels.getRowHeight();
420
                                        int rowClicked = (whereY - bounds.y) / rowHeight;
421
                                        ISymbol sym = (ISymbol) tblLevels.
422
                                                                                        getModel().
423
                                                                                        getValueAt(
424
                                                                                                rowClicked,
425
                                                                                                SYMBOL_COLUMN_INDEX);
426
                                        if (sym instanceof IMultiLayerSymbol) {
427
                                                summary.sym = (IMultiLayerSymbol) sym;
428
                                                summary.rowIndex = rowClicked;
429
                                        } else {
430
                                                summary.sym = null;
431
                                        }
432
                                        repaint();
433
                                }
434
                        }
435

    
436
                });
437

    
438
        }
439

    
440
        private JCheckBox getChkSpecifyDrawOrder() {
441
                if (chkSpecifyDrawOrder == null) {
442
                        chkSpecifyDrawOrder = new JCheckBox("<html><b>"+
443
                                        Messages.getText("draw_symbols_in_specified_order")
444
                                        +"</b></html>");
445
                        chkSpecifyDrawOrder.addActionListener(this);
446
                }
447
                return chkSpecifyDrawOrder;
448
        }
449

    
450

    
451
        private JPanel getPnlCenter() {
452
                if (pnlCenter == null) {
453
                        pnlCenter = new JPanel();
454
                        pnlCenter.setLayout(new BorderLayout(0, 15));
455
                        pnlCenter.add(getSrclLevels(), BorderLayout.CENTER);
456
                        pnlCenter.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
457
                        JPanel aux = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 15));
458
                        JPanel pnlButtons = new JPanel();
459
                        pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.Y_AXIS));
460
                        pnlButtons.add(new JBlank(1, 70));
461
                        pnlButtons.add(getBtnUp());
462
                        pnlButtons.add(new JBlank(1, 10));
463
                        pnlButtons.add(getBtnDown());
464
                        pnlButtons.setVisible(false);
465
                        aux.add(pnlButtons);
466
                        pnlCenter.add(aux, BorderLayout.EAST);
467

    
468
                }
469
                pnlCenter.setEnabled(getChkSpecifyDrawOrder().isSelected());
470
                return pnlCenter;
471
        }
472

    
473
        private JScrollPane getSrclLevels() {
474
                if (srclLevels == null) {
475
                        srclLevels = new JScrollPane();
476
                        srclLevels.setViewportView(getTblLevels());
477
                }
478
                srclLevels.setEnabled(getChkSpecifyDrawOrder().isSelected());
479
                return srclLevels;
480
        }
481

    
482

    
483
        private JTable getTblLevels() {
484
                if (tblLevels == null) {
485
                        tblLevels = new JTable() {
486
                                private static final long serialVersionUID = -1545710722048183232L;
487

    
488
                                @Override
489
                                protected void paintComponent(Graphics g) {
490
                                        super.paintComponent(g);
491
                                        summary.paint((Graphics2D) g);
492
                }
493
                        };
494
                        summary.rowHeight = tblLevels.getRowHeight();
495
                }
496
                tblLevels.setEnabled(getChkSpecifyDrawOrder().isSelected());
497
                return tblLevels;
498
        }
499

    
500

    
501
        private JButton getBtnUp() {
502
                if (btnUp == null) {
503
                        btnUp = new JButton(PluginServices.getIconTheme().get("arrow-up-icono"));
504
                        btnUp.setActionCommand("MOVE_UP");
505
                }
506
                return btnUp;
507
        }
508

    
509
        private JButton getBtnDown() {
510
                if (btnDown == null) {
511
                        btnDown = new JButton(PluginServices.getIconTheme().get("arrow-down-icono"));
512
                        btnDown.setActionCommand("MOVE_DOWN");
513
                }
514
                return btnDown;
515
        }
516

    
517

    
518
        private JPanel getPnlSouth() {
519
                if (pnlSouth == null) {
520
                        pnlSouth = new JPanel(new BorderLayout());
521
                        JPanel aux = new JPanel();
522
                        aux.setLayout(new FlowLayout(FlowLayout.RIGHT));
523
                        aux.add(getBtnSwitchView());
524
                        pnlSouth.add(aux, BorderLayout.NORTH);
525

    
526
                        aux = new JPanel();
527
                        aux.setLayout(new FlowLayout(FlowLayout.RIGHT));
528
                        pnlSouth.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH);
529

    
530
                }
531
                return pnlSouth;
532
        }
533

    
534
        private JButton getBtnSwitchView() {
535
                if (btnSwitchView == null) {
536
                        btnSwitchView = new JButton(
537
                                        (viewMode != DEFAULT_VIEW) ?
538
                                        Messages.getText("default_view"):
539
                                        Messages.getText("advanced_view")
540
                                        );
541
                        btnSwitchView.addActionListener(this);
542
                        btnSwitchView.setVisible(false);
543
                }
544

    
545
                return btnSwitchView;
546
        }
547

    
548
        public void actionPerformed(ActionEvent e) {
549
                JComponent c = (JComponent) e.getSource();
550
                if (c.equals(getChkSpecifyDrawOrder())) {
551
                        getPnlCenter().setEnabled(getChkSpecifyDrawOrder().isSelected());
552
                        getSrclLevels().setEnabled(getChkSpecifyDrawOrder().isSelected());
553
                        TableCellEditor tce = getTblLevels().getCellEditor();
554
                        if (tce != null){
555
                                tce.stopCellEditing();
556
                        }
557
                        getTblLevels().setEnabled(getChkSpecifyDrawOrder().isSelected());
558
                } else if (c.equals(getBtnSwitchView())) {
559
                        viewMode = (viewMode == ADVANCED_VIEW) ? DEFAULT_VIEW : ADVANCED_VIEW;
560
                        initTableContents(getTblLevels(), zSort, viewMode);
561
                        btnSwitchView.setText((viewMode != DEFAULT_VIEW) ?
562
                                        Messages.getText("default_view"):
563
                                        Messages.getText("advanced_view"));
564
                }
565
        }
566
        /**
567
         * Gets the ZSort value
568
         *
569
         * @return zSort ZSort
570
         */
571
        public ZSort getZSort() {
572
                return zSort;
573
        }
574

    
575
        private class SymbolSummary {
576
                int witdh;
577
                int rowHeight = 10;
578

    
579
                int rowIndex;
580

    
581
                IMultiLayerSymbol sym;
582

    
583
                void paint(Graphics2D g){
584

    
585
                        if (sym != null) {
586
                                int whereY = (rowHeight*(rowIndex-1) + (int) (rowHeight/0.6));
587
                                int whereX = 0;
588
                                for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) {
589
                                        whereX += tblLevels.getColumnModel().getColumn(i).getWidth();
590
                                }
591
                                whereX -= 40;
592
                                int width = 150;
593
                                int height = Math.max(rowHeight*sym.getLayerCount(), rowHeight);
594
                                Rectangle bounds = new Rectangle(whereX, whereY, width, height);
595
                                g.setColor(new Color(255, 255, 220));
596
                                g.fill(bounds);
597

    
598
                                g.setColor(new Color(255, 230, 20));
599
                                g.draw(bounds);
600

    
601
                                g.setFont(new Font("Arial", Font.BOLD, 10));
602

    
603
                                for (int i = 0; i < sym.getLayerCount(); i++) {
604
                                        g.setColor(Color.black);
605
                                        g.drawString(i+1+":", whereX+5, height + whereY - ( (i*rowHeight) + 5 ));
606
                                        Rectangle rect = new Rectangle(whereX + 20,
607
                                                        height + whereY - ((i+1)*rowHeight) + 3,
608
                                                        width - 20,
609
                                                        rowHeight - 6);
610
                                        try {
611
                                                sym.getLayer(i).drawInsideRectangle(g, null, rect,null);
612
                                        } catch (SymbolDrawingException e) {
613
                                                if (e.getType() == SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS) {
614
                                                        try {
615
                                                                MapContextLocator.getSymbolManager()
616
                                                                                .getWarningSymbol(
617
                                                                                                SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS,
618
                                                                                                "",
619
                                                                                                SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS)
620
                                                                                .drawInsideRectangle(g, null, rect,
621
                                                                                                null);
622
                                                        } catch (SymbolDrawingException e1) {
623
                                                                // IMPOSSIBLE TO REACH THIS
624
                                                        }
625
                                                } else {
626
                                                        // should be unreachable code
627
                                                        throw new Error(Messages.getText("symbol_shapetype_mismatch"));
628
                                                }
629
                                        }
630
                                }
631

    
632
                        }
633
                };
634
        }
635

    
636
        public Object getWindowProfile() {
637
                return WindowInfo.DIALOG_PROFILE;
638
        }
639

    
640
}